掲示板

Service Builder - Problem with Long-values

13年前 に Patrick Eggert によって更新されました。

Service Builder - Problem with Long-values

New Member 投稿: 1 参加年月日: 10/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:

com.liferay.portal.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.MappingException: Unknown entity: de.myapp.invoicing.model.impl.InvoicingUserExtImpl
	at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:97)
	at de.myapp.invoicing.service.persistence.InvoicingUserExtPersistenceImpl.fetchByPrimaryKey(InvoicingUserExtPersistenceImpl.java:287)
	... 
Caused by: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.MappingException: Unknown entity: de.myapp.invoicing.model.impl.InvoicingUserExtImpl
	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 de.myapp.invoicing.service.persistence.InvoicingUserExtPersistenceImpl.fetchByPrimaryKey(InvoicingUserExtPersistenceImpl.java:283)
	... 200 more
Caused by: org.hibernate.MappingException: Unknown entity: de.myapp.invoicing.model.impl.InvoicingUserExtImpl
	at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:580)
	at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:91)
	at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:842)
	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:835)
	at com.liferay.portal.dao.orm.hibernate.LiferaySession.get(LiferaySession.java:181)
	at com.liferay.portal.dao.orm.hibernate.SessionImpl.get(SessionImpl.java:128)
	... 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:

<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

<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
thumbnail
13年前 に Iván Rodríguez Bautista によって更新されました。

RE: Service Builder - Problem with Long-values

Regular Member 投稿: 166 参加年月日: 10/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:

<model name="com.mundopetroleo.comparador.model.EstacionServicio">
	<field name="id_field" type="long" />
	<field name="field_1" type="long" />
	<field name="field_2" type="long" />
	[.....]
	<field name="field_long_text" type="String">
		<hint name="max-length">255</hint>
	</field>
	[.....]
</model>


Maybe this will helps you.

Greetings!
thumbnail
10年前 に Abdollah Esmaeilpour によって更新されました。

RE: Service Builder - Problem with Long-values

Junior Member 投稿: 60 参加年月日: 09/08/22 最新の投稿
Hello Patrick

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

So many thanks.emoticon