Fórumok

Nyitólap » Liferay Portal » English » 3. Development

Kombinált nézet Egyszerű nézet Fa-nézet
Szálak [ Előző | Következő ]
toggle
Patrick Eggert
Service Builder - Problem with Long-values
2010. november 29. 1:41
Válasz

Patrick Eggert

Rangsorolás: New Member

Hozzászólások: 1

Csatlakozás dátuma: 2010. november 18.

Legújabb hozzászólások

Hello everybody.

I am using Service Builder with Liferay 5.2.5 (ee). In my database schema I have some foreign keys which may also be not set. So instead of using the "long"-type for these attributes, I am using the type "Long", so also null-values can be represented.
The generated source is compliled correctly and the war-file is deployed without any errors. When I try to read or write such an object the following exception occurs:

 1com.liferay.portal.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.MappingException: Unknown entity: de.myapp.invoicing.model.impl.InvoicingUserExtImpl
 2    at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:97)
 3    at de.myapp.invoicing.service.persistence.InvoicingUserExtPersistenceImpl.fetchByPrimaryKey(InvoicingUserExtPersistenceImpl.java:287)
 4    ...
 5Caused by: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.MappingException: Unknown entity: de.myapp.invoicing.model.impl.InvoicingUserExtImpl
 6    at com.liferay.portal.dao.orm.hibernate.ExceptionTranslator.translate(ExceptionTranslator.java:41)
 7    at com.liferay.portal.dao.orm.hibernate.SessionImpl.get(SessionImpl.java:131)
 8    at de.myapp.invoicing.service.persistence.InvoicingUserExtPersistenceImpl.fetchByPrimaryKey(InvoicingUserExtPersistenceImpl.java:283)
 9    ... 200 more
10Caused by: org.hibernate.MappingException: Unknown entity: de.myapp.invoicing.model.impl.InvoicingUserExtImpl
11    at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:580)
12    at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:91)
13    at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
14    at org.hibernate.impl.SessionImpl.get(SessionImpl.java:842)
15    at org.hibernate.impl.SessionImpl.get(SessionImpl.java:835)
16    at com.liferay.portal.dao.orm.hibernate.LiferaySession.get(LiferaySession.java:181)
17    at com.liferay.portal.dao.orm.hibernate.SessionImpl.get(SessionImpl.java:128)
18    ... 201 more


After some research I noticed that the problem seems to be the generated hibernate-mapping. For the "Long"-attributes, entries are created like this:

1<property name="someForeignKey" />


There is no type defined in this tag. Although hibernate seems to allow not explicitly defining the type in general, this seems to be the problem. When I replace this line by

1<property name="someForeignKey" type="java.lang.Long" />


everything is working fine. A closer look at service-builder's template file for the hibernate mapping told me that the type is only written into the mapping file for primitive types and String. Does anybody know why?

Does anybody have the same problem like me? Or am I the only one who's using the Long-type?
Is this behavior a bug or a feature? emoticon

Thanks in advance and wishes from Germany,
Patrick
Iván Rodríguez Bautista
RE: Service Builder - Problem with Long-values
2010. november 29. 2:49
Válasz

Iván Rodríguez Bautista

Rangsorolás: Regular Member

Hozzászólások: 158

Csatlakozás dátuma: 2010. január 25.

Legújabb hozzászólások

Hi Patrick,

Did you try editing "portlet-model-hints.xml" file in your-portlet/docroot/WEB-INF/src/META-INF??

There you can define the size of the Strings fields like this:
 1
 2<model name="com.mundopetroleo.comparador.model.EstacionServicio">
 3    <field name="id_field" type="long" />
 4    <field name="field_1" type="long" />
 5    <field name="field_2" type="long" />
 6    [.....]
 7    <field name="field_long_text" type="String">
 8        <hint name="max-length">255</hint>
 9    </field>
10    [.....]
11</model>


Maybe this will helps you.

Greetings!