Hi there!
I am quite new to Hibernate (if I do something very stupid)
I code agains a legacy database with composite keys. I then run the application... but the object then contains no data... I can see from the log that i record was returned (with the correct data). What am I doing wrong??
Here is the code snipped:
===START===============
//HIBERNATE
Session newSession = HibernateUtil.getSessionFactory().openSession();
DocumentHeaderID dhid = new DocumentHeaderID("6 ASU BP 001","1.00");
System.out.println("BEFORE LOAD");
DocumentHeader dh = (DocumentHeader)newSession.load(DocumentHeader.class, dhid);
System.out.println("AFTER LOAD");
System.out.println("DOC_CDE = " + dh.getDOC_CDE());
===END================
The log for this code looks like this:
===START===============
12:56:52,953 DEBUG SessionImpl:219 - opened session at timestamp: 11625514129
BEFORE LOAD
12:56:52,953 DEBUG DefaultLoadEventListener:153 - loading entity: [za.sita.model.DocumentHeader#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:52,953 DEBUG DefaultLoadEventListener:230 - creating new proxy for entity
12:56:53,000 DEBUG JDBCContext:217 - after autocommit
12:56:53,000 DEBUG ConnectionManager:398 - aggressively releasing JDBC connection
12:56:53,000 DEBUG SessionImpl:417 - after transaction completion
AFTER LOAD
12:56:53,000 DEBUG SessionImpl:816 - initializing proxy: [za.sita.model.DocumentHeader#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:53,000 DEBUG DefaultLoadEventListener:304 - attempting to resolve: [za.sita.model.DocumentHeader#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:53,000 DEBUG DefaultLoadEventListener:340 - object not resolved in any cache: [za.sita.model.DocumentHeader#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:53,000 DEBUG AbstractEntityPersister:2723 - Fetching entity: [za.sita.model.DocumentHeader#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:53,000 DEBUG Loader:1777 - loading entity: [za.sita.model.DocumentHeader#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:53,000 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
12:56:53,000 DEBUG ConnectionManager:415 - opening JDBC connection
12:56:53,000 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
12:56:53,000 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
12:56:53,000 DEBUG SQL:346 - select documenthe0_.DOC_CDE as DOC1_0_0_, documenthe0_.DOC_VER as DOC2_0_0_, documenthe0_.OWNER_CDE as OWNER3_0_0_, documenthe0_.TYPE_CDE as TYPE4_0_0_, documenthe0_.DOC_DSC as DOC5_0_0_ from DOC_HEADER documenthe0_ where documenthe0_.DOC_CDE=? and documenthe0_.DOC_VER=?
Hibernate: select documenthe0_.DOC_CDE as DOC1_0_0_, documenthe0_.DOC_VER as DOC2_0_0_, documenthe0_.OWNER_CDE as OWNER3_0_0_, documenthe0_.TYPE_CDE as TYPE4_0_0_, documenthe0_.DOC_DSC as DOC5_0_0_ from DOC_HEADER documenthe0_ where documenthe0_.DOC_CDE=? and documenthe0_.DOC_VER=?
12:56:53,000 DEBUG AbstractBatcher:424 - preparing statement
12:56:53,093 DEBUG StringType:80 - binding '6 ASU BP 001' to parameter: 1
12:56:53,093 DEBUG StringType:80 - binding '1.00' to parameter: 2
12:56:53,140 DEBUG AbstractBatcher:327 - about to open ResultSet (open ResultSets: 0, globally: 0)
12:56:53,140 DEBUG Loader:682 - processing result set
12:56:53,140 DEBUG Loader:687 - result set row: 0
12:56:53,156 DEBUG Loader:1164 - result row: EntityKey[za.sita.model.DocumentHeader#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:53,156 DEBUG Loader:1347 - Initializing object from ResultSet: [za.sita.model.DocumentHeader#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:53,156 DEBUG AbstractEntityPersister:1860 - Hydrating entity: [za.sita.model.DocumentHeader#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:53,156 DEBUG StringType:122 - returning '6 ASU' as column: OWNER3_0_0_
12:56:53,156 DEBUG StringType:122 - returning 'BP' as column: TYPE4_0_0_
12:56:53,156 DEBUG StringType:122 - returning 'ASU BUSINESS PLAN ALO III' as column: DOC5_0_0_
12:56:53,156 DEBUG Loader:709 - done processing result set (1 rows)
12:56:53,156 DEBUG AbstractBatcher:334 - about to close ResultSet (open ResultSets: 1, globally: 1)
12:56:53,156 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
12:56:53,156 DEBUG AbstractBatcher:470 - closing statement
12:56:53,156 DEBUG Loader:839 - total objects hydrated: 1
12:56:53,156 DEBUG TwoPhaseLoad:107 - resolving associations for [za.sita.model.DocumentHeader#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:53,171 DEBUG CollectionLoadContext:141 - creating collection wrapper:[za.sita.model.DocumentHeader.topics#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:53,171 DEBUG TwoPhaseLoad:206 - done materializing entity [za.sita.model.DocumentHeader#component[DOC_CDE,DOC_VER]{DOC_CDE=6 ASU BP 001, DOC_VER=1.00}]
12:56:53,171 DEBUG StatefulPersistenceContext:748 - initializing non-lazy collections
12:56:53,171 DEBUG Loader:1808 - done entity load
DOC_CDE = null
===END================
The last sys out confrims the NULL value. But the log says i record wqas returnd... how come this data does not end up in my "dh" object?
Appreciate!
Giovanni
|