Foren
Long and Integer problem with null in db in liferay 6.0.5
Mat Cuha, geändert vor 13 Jahren.
Long and Integer problem with null in db in liferay 6.0.5
New Member Beiträge: 2 Beitrittsdatum: 15.12.10 Neueste Beiträge
hi to all,
i have proglem with foreign keys and other values in my db tables. Every my FK is Long value and in liferay 5.3 i have no problem to add null value to table. With liferay 6.0.5 all null values are now 0, but i want it back to null and have option to save null or 0. I know that it is becouse of liferay add to all Long or Integer field in service.xml have in portal.hbm.xml set type to hibernate.LongType or IntegerType.
Have anybody fix to this?
cuha
i have proglem with foreign keys and other values in my db tables. Every my FK is Long value and in liferay 5.3 i have no problem to add null value to table. With liferay 6.0.5 all null values are now 0, but i want it back to null and have option to save null or 0. I know that it is becouse of liferay add to all Long or Integer field in service.xml have in portal.hbm.xml set type to hibernate.LongType or IntegerType.
Have anybody fix to this?
cuha
Jonas X. Yuan, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Hi Cuha,
Yes, a fix patch (for both LR 5.2 and LR 6) is here
applying convert-null element to service generator
The Service-Builder should be able to apply convert-null element on data type like "int", "Integer", "long", "short" etc.
Does it help?
Thanks
Jonas Yuan
==================
The Author of Liferay Books:
Liferay User Interface Development
Liferay Portal 6 Enterprise Intranets
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
Yes, a fix patch (for both LR 5.2 and LR 6) is here
applying convert-null element to service generator
The Service-Builder should be able to apply convert-null element on data type like "int", "Integer", "long", "short" etc.
Does it help?
Thanks
Jonas Yuan
==================
The Author of Liferay Books:
Liferay User Interface Development
Liferay Portal 6 Enterprise Intranets
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
Jonas X. Yuan, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
The updated patch would support any Primitive-Type like "boolean", "int", "integer", "long", "short", "float", "double".
Thanks
Jonas Yuan
Thanks
Jonas Yuan
Jonas X. Yuan, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
An workable example:
and sample generated SQL
<!--?xml version="1.0"?-->
<service-builder package-path="com.liferay.sampleservicebuilder">
<namespace>SSB</namespace>
<entity name="Foo" uuid="true" local-service="true" remote-service="true">
<!-- PK fields -->
<column name="fooId" type="long" primary="true" />
<!-- Group instance -->
<column name="groupId" type="long" />
<!-- Audit fields -->
<column name="companyId" type="long" />
<column name="userId" type="long" />
<column name="userName" type="String" />
<column name="createDate" type="Date" />
<column name="modifiedDate" type="Date" />
<!-- Other fields -->
<column name="field0" type="Integer" convert-null="false" />
<column name="field1" type="String" />
<column name="field2" type="boolean" />
<column name="field3" type="int" />
<column name="field4" type="Date" />
<column name="field5" type="String" />
<column name="field6" type="long" convert-null="false" />
<column name="field7" type="long" convert-null="true" />
<column name="field8" type="short" convert-null="false" />
<column name="field9" type="short" convert-null="true" />
<column name="fieldA" type="int" convert-null="false" />
<column name="fieldB" type="boolean" convert-null="false" />
<column name="fieldC" type="float" convert-null="true" />
<column name="fieldD" type="float" convert-null="false" />
<column name="fieldE" type="double" convert-null="true" />
<column name="fieldF" type="double" convert-null="false" />
<!-- Order -->
<order by="asc">
<order-column name="field1" />
</order>
<!-- Finder methods -->
<finder name="Field2" return-type="Collection">
<finder-column name="field2" />
</finder>
<!-- References -->
<reference package-path="com.liferay.portlet.asset" entity="AssetEntry" />
<reference package-path="com.liferay.portlet.asset" entity="AssetTag" />
</entity>
</service-builder>
and sample generated SQL
create table SSB_Foo (
uuid_ VARCHAR(75) null,
fooId LONG not null primary key,
groupId LONG,
companyId LONG,
userId LONG,
userName VARCHAR(75) null,
createDate DATE null,
modifiedDate DATE null,
field0 INTEGER null,
field1 VARCHAR(75) null,
field2 BOOLEAN,
field3 INTEGER,
field4 DATE null,
field5 VARCHAR(75) null,
field6 LONG null,
field7 LONG,
field8 INTEGER null,
field9 INTEGER,
fieldA INTEGER null,
fieldB BOOLEAN null,
fieldC DOUBLE,
fieldD DOUBLE null,
fieldE DOUBLE,
fieldF DOUBLE null
);
Michal Cisty, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
New Member Beiträge: 5 Beitrittsdatum: 12.01.11 Neueste Beiträge
Hi Jonas!
Great!
When will be the patch available?
Cheers.
Michal
Great!
When will be the patch available?
Cheers.
Michal
Jonas X. Yuan, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Hi Michal,
The fix patch is ready for testing.
Which version are you using? LR 6.0.5 CE?
By the way, you may refer to blogs post
Applying convert-null attribute in Service Builder to persist NULL and NOT NULL into data types in databases
Thanks
Jonas Yuan
The fix patch is ready for testing.
Which version are you using? LR 6.0.5 CE?
By the way, you may refer to blogs post
Applying convert-null attribute in Service Builder to persist NULL and NOT NULL into data types in databases
Thanks
Jonas Yuan
Minhchau Dang, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
Liferay Master Beiträge: 598 Beitrittsdatum: 22.10.07 Neueste BeiträgeJonas X. Yuan:
The fix patch is ready for testing.
Where did you attach the patch?
Jonas X. Yuan, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Hi Minhchau
The fix patch will be ready for trunk version 6.1 shortly at
http://issues.liferay.com/browse/LPS-14863
Before uploading the fix patch, I prefer that more tests can be done at 5.2 and 6.0.
Which version do you want to test?
Thanks
Jonas Yuan
The fix patch will be ready for trunk version 6.1 shortly at
http://issues.liferay.com/browse/LPS-14863
Before uploading the fix patch, I prefer that more tests can be done at 5.2 and 6.0.
Which version do you want to test?
Thanks
Jonas Yuan
Minhchau Dang, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
Liferay Master Beiträge: 598 Beitrittsdatum: 22.10.07 Neueste BeiträgeJonas X. Yuan:
Which version do you want to test?
I would only test it against trunk. I was just curious, because based on all your posts and on your blog entry, it sounded like you already attached the patch for review somewhere, and I didn't see it attached to the LPS ticket.
Jonas X. Yuan, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Hi Minhchau,
The fix patch for trunk version (revision 71297) is ready at http://issues.liferay.com/browse/LPS-14863.
It would be nice that you could test and give your feedback.
Thanks
Jonas Yuan
==================
The Author of Liferay Books:
Liferay User Interface Development
Liferay Portal 6 Enterprise Intranets
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
The fix patch for trunk version (revision 71297) is ready at http://issues.liferay.com/browse/LPS-14863.
It would be nice that you could test and give your feedback.
Thanks
Jonas Yuan
==================
The Author of Liferay Books:
Liferay User Interface Development
Liferay Portal 6 Enterprise Intranets
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
Michal Cisty, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
New Member Beiträge: 5 Beitrittsdatum: 12.01.11 Neueste Beiträge
Hi Jonas.
Yes, I am using the version LR 6.0.5 CE.
Yes, I am using the version LR 6.0.5 CE.
Jonas X. Yuan, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Hi Michal, Thanks,
You can test this new feature in following steps.
1. Save the attached patch lps9022-servicebuilder-ce6050-portal-impl-jdk5.jar file in Liferay Portal 6.0.5 CE $TOMCAT_WEBAPPS/ROOT/WEB-INF/lib folder
2. rebuild your services from servier.xml file
3. Restart your Tomcat
4. Rebuild your portlet
5. Redeploy your portlet
6. Test
Please let me know if you meet any issues.
Jonas Yuan
==================
The Author of Liferay Books:
Liferay User Interface Development
Liferay Portal 6 Enterprise Intranets
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
You can test this new feature in following steps.
1. Save the attached patch lps9022-servicebuilder-ce6050-portal-impl-jdk5.jar file in Liferay Portal 6.0.5 CE $TOMCAT_WEBAPPS/ROOT/WEB-INF/lib folder
2. rebuild your services from servier.xml file
3. Restart your Tomcat
4. Rebuild your portlet
5. Redeploy your portlet
6. Test
Please let me know if you meet any issues.
Jonas Yuan
==================
The Author of Liferay Books:
Liferay User Interface Development
Liferay Portal 6 Enterprise Intranets
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
Michal Cisty, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
New Member Beiträge: 5 Beitrittsdatum: 12.01.11 Neueste Beiträge
Hi Jonas.
Thanks very much for the instructions.
I have tried using the <convert-null> attribute on a foreign key.
Creating and updating the entity seems to be working, there was no longer a zero as the value of a null property in the database. Nice job!
However, I had a problem when using finders. I got a NullPointerException from within the method cacheResult(...) of the entityPersistenceImpl class.
I have tried to recreate the problem. This is the service.xml:
And the method in ConvertNullTestEntityPersistenceImpl class that throws the NullPointerException (the line number is 14):
It seems to me that the problem is that the constructor of the Long class receives a null reference in some cases.
Best regards. Michal
Thanks very much for the instructions.
I have tried using the <convert-null> attribute on a foreign key.
Creating and updating the entity seems to be working, there was no longer a zero as the value of a null property in the database. Nice job!
However, I had a problem when using finders. I got a NullPointerException from within the method cacheResult(...) of the entityPersistenceImpl class.
I have tried to recreate the problem. This is the service.xml:
<entity name="ConvertNullTestEntity" table="convertnulltest" local-service="true">
<!-- PK fields -->
<column name="entityId" type="long" primary="true" />
<!-- Foreign keys -->
<column name="notNullFK" type="Long" />
<column name="nullFK" type="Long" convert-null="false" />
<!-- Finder methods -->
<finder name="TestFinderOne" return-type="ConvertNullTestEntity">
<finder-column name="notNullFK" />
</finder>
<finder name="TestFinderTwo" return-type="ConvertNullTestEntity">
<finder-column name="notNullFK" />
<finder-column name="nullFK" />
</finder>
</entity>
And the method in ConvertNullTestEntityPersistenceImpl class that throws the NullPointerException (the line number is 14):
public void cacheResult(ConvertNullTestEntity convertNullTestEntity)
{
EntityCacheUtil.putResult(ConvertNullTestEntityModelImpl.ENTITY_CACHE_ENABLED,
ConvertNullTestEntityImpl.class,
convertNullTestEntity.getPrimaryKey(), convertNullTestEntity);
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TESTFINDERONE,
new Object[] { new Long(convertNullTestEntity.getNotNullFK()) },
convertNullTestEntity);
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TESTFINDERTWO,
new Object[] {
new Long(convertNullTestEntity.getNotNullFK()),
new Long(convertNullTestEntity.getNullFK())
}, convertNullTestEntity);
}
It seems to me that the problem is that the constructor of the Long class receives a null reference in some cases.
Best regards. Michal
Jonas X. Yuan, geändert vor 13 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Hi Michal,
Sorry to come back to you late.
Do you get the issue (using finders) fixed?
Thanks
Jonas
Sorry to come back to you late.
Do you get the issue (using finders) fixed?
Thanks
Jonas
Varun Arya, geändert vor 6 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
New Member Beiträge: 24 Beitrittsdatum: 02.03.17 Neueste Beiträge
Hi Jonas,
I am facing the same issue. I am using liferay 6.2. But neither <column name="parentId" type="long" convert-null="false" /> solve my issue nor <column name="parentId" type="Long" convert-null="false" /> this. It always saving 0.
I am facing the same issue. I am using liferay 6.2. But neither <column name="parentId" type="long" convert-null="false" /> solve my issue nor <column name="parentId" type="Long" convert-null="false" /> this. It always saving 0.
txapeldot ., geändert vor 6 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
Junior Member Beiträge: 87 Beitrittsdatum: 15.01.15 Neueste Beiträge
Hi:
Just to report the same behaviour that the one reported by Varun. I'm using Liferay 6.2 too. Is it about a bug in this version of Liferay?
Thanks.
Just to report the same behaviour that the one reported by Varun. I'm using Liferay 6.2 too. Is it about a bug in this version of Liferay?
Thanks.
Varun Arya, geändert vor 5 Jahren.
RE: Long and Integer problem with null in db in liferay 6.0.5
New Member Beiträge: 24 Beitrittsdatum: 02.03.17 Neueste Beiträgetxapeldot .:
Hi:
Just to report the same behaviour that the one reported by Varun. I'm using Liferay 6.2 too. Is it about a bug in this version of Liferay?
Thanks.
Hi, Have you found the solution regarding this. Please suggest.