-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: nulls in my query list with reverse engineered database
PostPosted: Mon Jun 23, 2008 3:31 am 
Newbie

Joined: Thu Mar 01, 2007 4:13 am
Posts: 4
Hi,

I have an issue with hibernate when trying to extract data from a reverse engineered table. When I query all the contents of the table with a simple HQL from TABLENAME most of the items in the list are null.

The only ones that are not returned are the ones with all the columns filled, all others that have some null items are returned as null objects.

PID ISOCODE COUNTRYNAME COUNTRYTYPE ENTRYDATE PRINTSEQUENCE ....
11 ASM American Samoa third country <null> 0 AAAUzhAAHAABbemAAP
12 ATA Antarctica <null> <null> <null> AAAUzhAAHAABbemAAQ
13 ATF French Southern Territories third country <null> 0 AAAUzhAAHAABbemAAR
14 ATG Antigua and Barbuda third country <null> 0 AAAUzhAAHAABbemAAS
15 AUS Australia third country <null> 0 AAAUzhAAHAABbemAAT
16 AUT Austria member state 1995-01-01 00:00:00.0 19 AAAUzhAAHAABbemAAU

e.g. From the example above, the only object to be returned would be PID 16, all the rest are retuned in the query list as nulls.

At first I believed this to be lazy fetching and added the 'fetch all properties' directive to the HQL.

Can someone point me in the correct direction to have the list populated correctly.


Thanks

Paul.





Hibernate version: 3.2.6

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 20, 2008 11:18:11 AM by Hibernate Tools 3.2.0.CR1 -->
<hibernate-mapping>
<class name="it.jrc.fish.transfer.dao.DwCountry" table="DW_COUNTRY" schema="CR2006_DWH">
<composite-id name="id" class="it.jrc.fish.transfer.dao.DwCountryId">
<key-property name="pid" type="big_decimal">
<column name="PID" precision="22" scale="0" />
</key-property>
<key-property name="isoCode" type="string">
<column name="ISO_CODE" length="3" />
</key-property>
<key-property name="countryName" type="string">
<column name="COUNTRY_NAME" length="50" />
</key-property>
<key-property name="countryType" type="string">
<column name="COUNTRY_TYPE" length="50" />
</key-property>
<key-property name="entryDate" type="date">
<column name="ENTRY_DATE" length="7" />
</key-property>
<key-property name="printSequence" type="java.lang.Short">
<column name="PRINT_SEQUENCE" precision="3" scale="0" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Session sourceSession = sourceSessionFactory.openSession();
Transaction tx1 = sourceSession.beginTransaction();

String className = classMappingsIterator.next().toString();
logger.info ( "@@@@@@@@@@@@@@ Processing " + className );
List currentList = sourceSession.createQuery ("from " + className + " fetch all properties" ).list();
logger.info ( "@@@@@@@@@@@@@@ List size " + currentList.size ( ) );
Iterator listIterator = currentList.iterator();
while ( listIterator.hasNext() )
{
logger.info ( "@@@@@@@@@@@@@@ Object is : " + (( it.jrc.fish.transfer.dao.DwCountry ) listIterator.next()) );
}
tx1.commit();
sourceSession.close();
logger.info ( "Close source Session to replicate " + className );
Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
47392 [main] INFO Replicator.process - Create source Session
47436 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Processing DwCountry
Hibernate: /* from DwCountry fetch all properties */ select dwcountry0_.PID as PID41_, dwcountry0_.ISO_CODE as ISO2_41_, dwcountry0_.COUNTRY_NAME as COUNTRY3_41_, dwcountry0_.COUNTRY_TYPE as COUNTRY4_41_, dwcountry0_.ENTRY_DATE as ENTRY5_41_, dwcountry0_.PRINT_SEQUENCE as PRINT6_41_ from CR2006_DWH.DW_COUNTRY dwcountry0_
48881 [main] INFO Replicator.process - @@@@@@@@@@@@@@ List : [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@1e492d8, null, null, it.jrc.fish.transfer.dao.DwCountry@141b736, null, null, null, it.jrc.fish.transfer.dao.DwCountry@1635484, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@41b635, it.jrc.fish.transfer.dao.DwCountry@216b59, it.jrc.fish.transfer.dao.DwCountry@1fb7565, null, null, it.jrc.fish.transfer.dao.DwCountry@1d83cf4, null, null, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@189d7eb, it.jrc.fish.transfer.dao.DwCountry@be8c3e, null, it.jrc.fish.transfer.dao.DwCountry@1e965e9, null, null, it.jrc.fish.transfer.dao.DwCountry@21b97e, null, null, null, it.jrc.fish.transfer.dao.DwCountry@190c99, null, null, null, null, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@8a1f38, null, null, null, null, null, null, null, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@7ae6d, null, null, null, it.jrc.fish.transfer.dao.DwCountry@4c94e5, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@aa559d, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@dabcea, it.jrc.fish.transfer.dao.DwCountry@a8a81c, it.jrc.fish.transfer.dao.DwCountry@b4faeb, null, null, null, null, null, null, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@1c5809e, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@17f1d92, null, null, null, null, null, null, null, null, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@6e8504, null, null, it.jrc.fish.transfer.dao.DwCountry@1dedb45, null, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@d9205, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, it.jrc.fish.transfer.dao.DwCountry@edbca8, it.jrc.fish.transfer.dao.DwCountry@1fcca7b, it.jrc.fish.transfer.dao.DwCountry@1517e5e, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]
48882 [main] INFO Replicator.process - @@@@@@@@@@@@@@ List size 240
48882 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48882 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48882 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48883 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48883 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48883 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48883 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48883 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48883 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48883 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48884 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48884 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48884 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48884 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48884 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48884 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48884 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : it.jrc.fish.transfer.dao.DwCountry@1e492d8
48885 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48885 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48885 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : it.jrc.fish.transfer.dao.DwCountry@141b736
48885 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null
48885 [main] INFO Replicator.process - @@@@@@@@@@@@@@ Object is : null

Problems with Session and transaction handling?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 9:34 am 
Beginner
Beginner

Joined: Wed Jun 11, 2008 4:43 am
Posts: 20
I'm having similar problems with nulls in my collections. If I look at the content of the DB, it looks ok but when I look at what is in my collections, I often have a first element which is null.
I use cascading (all,delete-orphans) and lists.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.