掲示板

problem with mapping-key in service.xml

13年前 に Carole Béatrice DEMGNE KAMDEM によって更新されました。

problem with mapping-key in service.xml

New Member 投稿: 7 参加年月日: 10/07/01 最新の投稿
Hi all,

I want to use a foreign key in my service.xml but when I execute my portlet, I have an com.liferay.portal.SystemException error. Let me explain the situation.

My service.xml is :

<service-builder package-path="com.mypackage">
   <namespace>mynamespace<namespace>
   <entity name="Animal" local-service="true" remote-service="false" />
      <!--PK fields -->
      <column name="idAnimal" type="Integer" primary="true" />
      <!--Other fields -->
      <column name="classification" type="String" />
      <column name="nbChild" type="Integer" />
   
   <entity name="Child" local-service="true" remote-service="false" />
      <!--PK fields -->
      <column name="idChild" type="Integer" primary="true" />
      <!--Other fields -->
      <column name="parent" type="Collection" entity="Animal" mapping-key="idAnimal" />
      <column name="age" type="Integer" />
   
</namespace></namespace></service-builder>


The attribute "parent" in the entity "Child" is a foreign key. It references "idAnimal" in the entity Animal.

I build the service.xml with no error but when I want to access (add a record, delete, ...) to "Child" entity I have this error

com.liferay.portal.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: Unknown entity: com.mypackage.model.impl.childImpl
	at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:91)
	at com.adminium.discussions.service.persistence.childPersistenceImpl.remove(childPersistenceImpl.java:128)
	at com.adminium.discussions.service.base.childLocalServiceBaseImpl.deletemessages(childLocalServiceBaseImpl.java:59)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
        .....
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:619)
Caused by: com.liferay.portal.kernel.dao.orm.ORMException: Unknown entity: com.mypackage.model.impl.childImpl
	at com.liferay.portal.dao.orm.hibernate.ExceptionTranslator.translate(ExceptionTranslator.java:41)
	at com.liferay.portal.dao.orm.hibernate.SessionImpl.get(SessionImpl.java:131)
	at com.adminium.discussions.service.persistence.messagesPersistenceImpl.remove(messagesPersistenceImpl.java:109)
	... 170 more
Dans le doView pour creer2 - Fin
29 juil. 2010 15:42:36 org.apache.catalina.startup.HostConfig checkResources
INFO: Repli (undeploy) de l'application web ayant pour chemin de contexte /myappli-portlet
15:42:37,657 INFO  [PortletHotDeployListener:381] Unregistering portlets for myappli-portlet
15:42:37,661 INFO  [PortletHotDeployListener:412] 1 portlet for myappli-portlet was unregistered


What's wrong ? Any idea ?

Thanks in advance for your help,
Carole
thumbnail
13年前 に Corné A によって更新されました。

RE: problem with mapping-key in service.xml

Liferay Legend 投稿: 1313 参加年月日: 06/10/03 最新の投稿
I have no errors when i removed some errors in your XML

especially "nbChild" >> "idChild"

<service-builder package-path="com.mypackage">
   <namespace>mynamespace</namespace>
   <entity name="Animal" local-service="true" remote-service="false">
      <!--PK fields -->
      <column name="idAnimal" type="Integer" primary="true" />
      <!--Other fields -->
      <column name="classification" type="String" />
      <column name="idChild" type="Integer" />
   </entity>
   <entity name="Child" local-service="true" remote-service="false">
      <!--PK fields -->
      <column name="idChild" type="Integer" primary="true" />
      <!--Other fields -->
      <column name="parent" type="Collection" entity="Animal" mapping-key="idAnimal" />
      <column name="age" type="Integer" />
   </entity>
</service-builder>
13年前 に Carole Béatrice DEMGNE KAMDEM によって更新されました。

RE: problem with mapping-key in service.xml

New Member 投稿: 7 参加年月日: 10/07/01 最新の投稿
Many thanks for your help Corné, but there an error when I try to add a new record in Child table. This error is

com.liferay.portal.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: Unknown entity: com.mypackage.model.impl.childImpl
	at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:91)
	at com.mypackage.service.persistence.childPersistenceImpl.updateImpl(childPersistenceImpl.java:240)
	at com.mypackage.service.persistence.childPersistenceImpl.update(childPersistenceImpl.java:213)
	at com.mypackage.service.persistence.childUtil.update(childUtil.java:73)
	at com.mypackage.service.impl.childLocalServiceImpl.addChild(childLocalServiceImpl.java:53)
	
        ...

	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:619)
Caused by: com.liferay.portal.kernel.dao.orm.ORMException: Unknown entity: com.mypackage.model.impl.childImpl
	at com.liferay.portal.dao.orm.hibernate.ExceptionTranslator.translate(ExceptionTranslator.java:41)
	at com.liferay.portal.dao.orm.hibernate.SessionImpl.merge(SessionImpl.java:165)
	at com.liferay.portal.service.persistence.BatchSessionImpl.update(BatchSessionImpl.java:52)
	at com.liferay.portal.service.persistence.BatchSessionUtil.update(BatchSessionUtil.java:53)
	at com.adminium.discussions.service.persistence.childPersistenceImpl.updateImpl(childPersistenceImpl.java:235)
	... 173 more



And when I add with phpmyadmin some records in child table, but when I execute my porlet I have 0 value although there are records in my child table.

Any help ?

Thanks in advance.
thumbnail
13年前 に Corné A によって更新されました。

RE: problem with mapping-key in service.xml

Liferay Legend 投稿: 1313 参加年月日: 06/10/03 最新の投稿
Maybe you could try primitives in stead of Objects

<service-builder package-path="com.mypackage">
   <namespace>mynamespace</namespace>
   <entity name="Animal" local-service="true" remote-service="false">
      <!--PK fields -->
      <column name="idAnimal" type="int" primary="true" />
      <!--Other fields -->
      <column name="classification" type="String" />
      <column name="nbChild" type="int" />
   </entity>
   <entity name="Child" local-service="true" remote-service="false">
      <!--PK fields -->
      <column name="idChild" type="int" primary="true" />
      <!--Other fields -->
      <column name="parent" type="Collection" entity="Animal" mapping-key="idAnimal" />
      <column name="age" type="int" />
   </entity>

</service-builder>