Liferayシンポジウム2015 | 2015年11月にシカゴで(詳細はこちら)


ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
Patrick Eggert
Service Builder - Problem with Long-values
2010/11/29 1:41

Patrick Eggert

ランク: New Member

投稿: 1

参加年月日: 2010/11/18


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(
 3    at de.myapp.invoicing.service.persistence.InvoicingUserExtPersistenceImpl.fetchByPrimaryKey(
 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(
 7    at com.liferay.portal.dao.orm.hibernate.SessionImpl.get(
 8    at de.myapp.invoicing.service.persistence.InvoicingUserExtPersistenceImpl.fetchByPrimaryKey(
 9    ... 200 more
10Caused by: org.hibernate.MappingException: Unknown entity: de.myapp.invoicing.model.impl.InvoicingUserExtImpl
11    at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(
12    at org.hibernate.event.def.DefaultLoadEventListener.onLoad(
13    at org.hibernate.impl.SessionImpl.fireLoad(
14    at org.hibernate.impl.SessionImpl.get(
15    at org.hibernate.impl.SessionImpl.get(
16    at com.liferay.portal.dao.orm.hibernate.LiferaySession.get(
17    at com.liferay.portal.dao.orm.hibernate.SessionImpl.get(
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,
Iván Rodríguez Bautista
RE: Service Builder - Problem with Long-values
2010/11/29 2:49

Iván Rodríguez Bautista

ランク: Regular Member

投稿: 163

参加年月日: 2010/01/25


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:
 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    [.....]

Maybe this will helps you.

Abdollah Esmaeilpour
RE: Service Builder - Problem with Long-values
2013/11/20 8:52

Abdollah Esmaeilpour

ランク: Junior Member

投稿: 42

参加年月日: 2009/08/22


Hello Patrick

I had similar problem with "Integer".
I could solve my problem using your info.

So many thanks.emoticon