Doctrine 2 unknown column type requested - symfony

I'm trying to update my doctrine schema with the command:
php app/console doctrine:schema:update --force
I'm getting this error:
[Doctrine\DBAL\DBALException]
Unknown column type requested.
I'm getting this error since I've updated the xml mapping of the user entity in the Sonata UserBundle like this:
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Sonata\UserBundle\Entity\User" table="fos_user_user" repository-class="Application\Sonata\UserBundle\Repository\UserRepository">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="name" type="string" length="50" />
<field name="birthdate" type="date" />
<field name="natRanking" type="string" length="10" />
<field name="interNatRanking" type="string" length="10" nullable="true" />
<field name="natDoublesRanking" type="string" length="10" />
<field name="interNatDoublesRanking" type="string" length="10" nullable="true" />
<field name="doublesPartner" type="string" length="50" nullable="true" />
<field name="nationality" type="string" length="50" />
<field name="fileName" type="string" length="255" nullable="true" />
<field name="path" type="string" length="255" nullable="true" />
<field name="file" />
<many-to-many field="teams" target-entity="Tennisconnect\DashboardBundle\Entity\Team" mapped-by="players">
<join-table name="team_user">
<join-columns>
<join-column name="team_id" referenced-column-name="id"/>
</join-columns>
<inverse-join-columns>
<join-column name="user_id" referenced-column-name="id"/>
</inverse-join-columns>
</join-table>
</many-to-many>
<one-to-many field="my_friends" target-entity="Friend" mapped-by="friends_of_mine" />
<one-to-many field="friended_me" target-entity="Friend" mapped-by="friends_with_me" />
</entity>

Is the type of the field "file" missing?

Related

SOLR: Document is missing mandatory uniqueKey field: id

I have just started with the solr-6.5.1, trying to import data from Oracle DB.
My data does not have any Unique ID, searched through various forums and found out that using class="solr.UUIDUpdateProcessorFactory" this can be resolved. but stil getting the same error. below is the snippet of my managed-schema and solrconfig.xml.
solrconfig.xml
<requestHandler name="/update" class="solr.UpdateRequestHandler">
<lst name="defaults">
<str name="update.chain">uuid</str>
</lst>
</requestHandler>
<updateRequestProcessorChain name="uuid">
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
managed-schema
<field name="id" type="uuid" indexed="true" stored="true" required="true" />
<field name="SERVICEACCOUNTNUMBER" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="USERNAME" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="NAME" type="string" indexed="true" stored="true" multiValued="false" />
<field name="TRANSACTION_DATE" type="date" indexed="true" stored="true" />
<field name="PROCESSSTATUS" type="string" indexed="true" stored="true" />
<field name="RECHARGE_MODE" type="string" indexed="true" stored="true" />
<field name="PROCESSRECHARGEREQUESTNO" type="string" indexed="true" stored="true" />
<field name="PACKAGE_ID" type="string" indexed="true" stored="true" />
<field name="PACKAGENAME" type="string" indexed="true" stored="true" />
<field name="AMOUNT" type="int" indexed="true" stored="true" multiValued="true" />
<field name="CREDITDOCUMENTNUMBER" type="string" indexed="true" stored="true" multiValued="true" />
<field name="DEBITDOCUMENTNUMBER" type="string" indexed="true" stored="true" />
<field name="SERVICE_TYPE" type="string" indexed="true" stored="true" multiValued="true" />
Please help
answer credits to post solr uuid with error document is missing mandatory uniquekey field id
updated the solrconfig.xml to
<requestHandler name="/dataimport" class="solr.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
<str name="update.chain">uuid</str>
</lst>
</requestHandler>
<updateRequestProcessorChain name="uuid">
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
<processor class="solr.RunUpdateProcessorFactory"/>
</updateRequestProcessorChain>

fosrestBundle and SonataUserBundle new fields serilalisation

i'm using the SonataUserBundle extended under src/Application/Sonata/UserBundle and i added some extra fields in src/Application/Sonata/UserBundle/Resources/config/doctrine/User.orm.xml
<entity name="Application\Sonata\UserBundle\Entity\User" table="ez_user">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<many-to-many field="groups" target-entity="Application\Sonata\UserBundle\Entity\Group">
<join-table name="ez_user_group">
<join-columns>
<join-column name="user_id" referenced-column-name="id"/>
</join-columns>
<inverse-join-columns>
<join-column name="group_id" referenced-column-name="id"/>
</inverse-join-columns>
</join-table>
</many-to-many>
<many-to-one field="media" target-entity="Application\Sonata\MediaBundle\Entity\Media">
<cascade>
<cascade-all/>
</cascade>
</many-to-one>
<field name="companyName" column="company_name" type="string" length="255" nullable="true" />
<field name="companyPhone" column="company_phone" type="integer" nullable="true" />
</entity>
getter and setter added in src/Application/Sonata/UserBundle/Entity/User.php
my config.yml is like this
fos_user:
db_driver: orm
firewall_name: main
user_class: Application\Sonata\UserBundle\Entity\User
group:
group_class: Application\Sonata\UserBundle\Entity\Group
group_manager: sonata.user.orm.group_manager
service:
user_manager: sonata.user.orm.user_manager
sonata_user:
security_acl: true
manager_type: orm
class:
user: Application\Sonata\UserBundle\Entity\User
group: Application\Sonata\UserBundle\Entity\Group
jms_serializer:
metadata:
directories:
FOSUB:
namespace_prefix: "FOS\\UserBundle"
path: "%kernel.root_dir%/serializer/FOSUserBundle"
app/serializer/FOSUserBundle/Model.User.xml :
<serializer>
<class name="FOS\UserBundle\Model\User" exclusion-policy="all" xml-root-name="user">
<property name="username" type="string" expose="true" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
<property name="usernameCanonical" type="string" expose="false" since-version="1.0" groups="sonata_api_read,sonata_search" />
<property name="email" type="string" expose="true" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
<property name="emailCanonical" type="string" expose="false" since-version="1.0" groups="sonata_api_read,sonata_search" />
<property name="enabled" type="boolean" expose="false" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
<property name="plainPassword" type="string" expose="false" since-version="1.0" groups="sonata_api_write" />
<property name="lastLogin" type="DateTime" expose="false" since-version="1.0" groups="sonata_api_read,sonata_search" />
<property name="locked" type="boolean" expose="false" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
<property name="expired" type="boolean" expose="false" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
<property name="expiresAt" type="DateTime" expose="false" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
<property name="confirmationToken" type="string" expose="false" since-version="1.0" groups="sonata_api_read,sonata_search" />
<property name="passwordRequestedAt" type="DateTime" expose="false" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
<property name="roles" type="array" expose="false" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
<property name="credentialsExpired" type="boolean" expose="false" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
<property name="credentialsExpireAt" type="DateTime" expose="false" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
<property name="gender" expose="false" />
<property name="createdAt" type="DateTime" expose="false" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
<property name="updatedAt" type="DateTime" expose="false" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
</class>
the jms section in the config is to hide some properties like (password, salt, etc) from api return data
my probleme is in my api a dan't get the new fields added in SonataUserBundles (media, comanyName)
any idea ?

How to search from database using solr

Solr Version : 5.0
So I am working on Solr for first time, and really not understand perfectly. Here what I did :-
I have created a core named - search
Then my schema.xml file has follwoing code :
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="simple" version="1.5">
<types>
<fieldtype name='string' class='solr.StrField' />
<fieldtype name='long' class='solr.TrieLongField' />
</types>
<fields>
<field name='id' type='int' required='true' indexed="true"/>
<field name='name' type='text' required='true' indexed="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>fullText</defaultSearchField>
<solrQueryParser defaultOperator='OR' />
</schema>
solrconfig.xml :
<?xml version='1.0' encoding='UTF-8' ?>
<config>
<luceneMatchVersion>5.0.0</luceneMatchVersion>
<lib dir="../../../../dist/" regex="solr-dataimporthandler-.*\.jar" />
<requestHandler name="standard" class="solr.StandardRequestHandler" default='true' />
<requestHandler name="/update" class="solr.UpdateRequestHandler" />
<requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">db-data-config.xml</str>
</lst>
</requestHandler>
<admin>
<defaultQuery>*:*</defaultQuery>
</admin>
</config>
db-data-config.xml :
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/solr"
user="root"
password="" />
<document>
<entity name="users" query="select id,name from users;" />
</document>
</dataConfig>
I have created a database on PHPmyadmin please find below SG :
when I clicked query on solr panel then it shows empty why ?
Can anyone help me on this, as I am new to solr search. What I am doing wrong ?
I dont see a field named "fulltext" in schema.xml but why its defined as the default search
<defaultSearchField>fullText</defaultSearchField>
change it
<defaultSearchField>name</defaultSearchField>
mention the fields in the data config xml
<field column="ID" name="id" />
<field column="NAME" name="name" />
your data-config should look alike
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/solr"
user="root"
password="" />
<document>
<entity name="users" query="select id,name from users">
<field column="ID" name="id" />
<field column="NAME" name="name" />
</entity>
</document>
</dataConfig>
add it as in schema.xml
<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
</types>
<fields>
<field name='id' type='int' required='true' indexed="true" stored="true"/>
<field name='name' type='string' required='true' indexed="true" stored="true"/>
<fields>
Make the changes in your db-data-config.xml similar to what i have done
<entity name="city_masters" pk="city_id" query="SELECT delete_status as
city_masters_delete_status,city_id,country_id,city_name,city_updated from
city_masters>
<field column="city_id" name="id"/>
<field column="city_name" name="city_name" indexed="true" stored="true" />
<field column="country_id" name="country_id" indexed="true" stored="true" />
<field column="city_masters_delete_status" name="city_masters_delete_status"
indexed="true" stored="true" />
</entity>
You missed out the field column part.Add them like i have done for my code and it should work.If still doesnt work let me know

sf2 - list of all groups with information if user joined this group

I start to model the db/entities in symfony2.
I have two entities. First is a User and second is a Groups.
I want to connect both. I think I should use many to many relations(?).
But my major problem is how can I get list of all groups with information if user joined this group.
Group Entity:
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="GroupBundle\Entity\Group">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
<field name="name" type="string" column="name" length="50"/>
<field name="description" type="string" column="description"/>
<many-to-many field="users" mapped-by="groups" target-entity="AccountBundle\Entity\User"/>
</entity>
</doctrine-mapping>
and User Entity:
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="AccountBundle\Entity\User">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
<field name="username" type="string" column="username" length="255"/>
<field name="password" type="string" column="password" length="255"/>
<field name="salt" type="string" column="salt" length="255"/>
<field name="email" type="string" column="email" length="255"/>
<field name="active" type="boolean" column="active"></field>
<field name="token" type="string" column="token" length="255"/>
<field name="lastLoginTime" type="datetime" column="lastLoginTime" nullable="true"/>
<field name="registerTime" type="datetime" column="registerTime"/>
<one-to-many field="events" target-entity="CoreBundle\Entity\Event" mapped-by="user" />
<many-to-many field="groups" inversed-by="users" target-entity="GroupBundle\Entity\Group">
<join-table name="UserGroups">
<join-columns>
<join-column name="userId" referenced-column-name="id" />
</join-columns>
<inverse-join-columns>
<join-column name="groupId" referenced-column-name="id" />
</inverse-join-columns>
</join-table>
</many-to-many>
</entity>
</doctrine-mapping>
There is no relation between there yet because I don't know what is best.
Maybe I must create additional Entity between like UserGroup?
D4V1D you have a right. Assumption is: User can join to many group and group can have a many user.
Okey I add the many-to-many relations. I hope I did it right.
And now. This is fragment of my controller:
$em = $this->getDoctrine()->getManager();
$repo = $em->getRepository("GroupBundle\Entity\Group");
$groups = $repo->findAll();
$user = $this->getUser();
$user_groups = $user->getGroups();
foreach($user_groups as $user_group){
/* #var $group Group */
foreach($groups as $group){
if($group->getId() == $user_group->getId()){
$group->setUserInGroup(true); // of course i extend my entity file about extra set and get method.
}
}
}
return $this->render('GroupBundle:showAll.html.twig', array('groups' => $groups));
and view:
{% for group in groups %}
<div>
{{ group.name }}
{% if(group.getUserInGroup()) %}
join
{% endif %}
</div>
{% endfor %}
I try find the best and right method to do this.
Without relation OneToMany with user and group, how do you join the group with user? which field have this information? you need a relation yes.
Group entity :
<many-to-many field="users" target-entity="AccountBundle\Entity\User" mapped-by="groups" />
User entity :
<many-to-many field="groups" target-entity="GroupBundle\Entity\Group" inversed-by="users"/>

doctrine2 (xml): in a one-to-many bidirectional relationship, can't get the infers side?

i have Banner and Group entities with xml configs
Banner.xml
<mapped-superclass name="Banner" table="luc_banners"
repository-class="BannerRepository">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="path" column="path" type="string" nullable="true" />
<field name="link" column="link" type="string" nullable="true" />
<field name="position" column="position" type="string" nullable="true" />
<field name="groupId" column="group_id" type="integer" />
<many-to-one field="group" target-entity="Group" inversed-by="banners">
<join-column name="group_id" referenced-column-name="id" nullable="false" on-delete="CASCADE" />
</many-to-one>
</mapped-superclass>
Group.xml
<mapped-superclass name="Group" table="luc_banners_groups" repository-class="GroupRepository">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="name" column="group_name" type="string" nullable="true" />
<field name="type" column="group_type" type="string" nullable="true" />
<field name="status" column="group_status" type="string" nullable="true" />
<field name="order" column="group_order" type="integer" nullable="true" />
<one-to-many field="banners" target-entity="Banners" mapped-by="group">
<cascade>
<cascade-all />
</cascade>
</one-to-many>
</mapped-superclass>
when trying to get banners form group object i get empty array, and Profiler shows this sql SELECT l0_.group_name AS group_name0, l0_.id AS id4 FROM luc_banners_groups l0_ WHERE l0_.group_status = ? and show not valid entity with this error Banner - The association Banner#group refers to the inverse side field Group#banners which does not exist.
Can you help me with this thing ?
remove <field name="groupId" column="group_id" type="integer" /> from Banner.xml, I think it's overriding the second one..

Resources