-->
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.  [ 7 posts ] 
Author Message
 Post subject: how to mapping a composite-id table to a set
PostPosted: Thu Apr 29, 2004 11:52 pm 
Newbie

Joined: Thu Apr 29, 2004 11:15 pm
Posts: 8
hi

when i want to mapping the three table
table a
ida sequence pk;
other column

talbe b
idb sequence pk;
other column

table ab
ida pk fk;
idb pk fkl
other column

i want to use a set to mapping table ab in class a for table a.
how do i handle this problem.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 30, 2004 12:06 am 
Newbie

Joined: Thu Apr 29, 2004 11:41 pm
Posts: 4
Location: Columbus, OH
Use a many-to-many mapping with set semantics. When you specify table name, that will be your "table ab" and will map the foreign keys. You can specify an "element" for additional fields.

_________________
. . .

Jess


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 30, 2004 1:35 am 
Newbie

Joined: Thu Apr 29, 2004 11:15 pm
Posts: 8
jbalint wrote:
Use a many-to-many mapping with set semantics. When you specify table name, that will be your "table ab" and will map the foreign keys. You can specify an "element" for additional fields.


thx.
but i cant use both many-to-many and elements for the tag set.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 30, 2004 2:11 am 
Newbie

Joined: Thu Apr 29, 2004 11:15 pm
Posts: 8
<set name="usertofunc" table="USERTOFUNC" lazy="true">
<key column="EMPSEQNO"/>



<composite-element class="Usertofunc">
<many-to-one name="sysmenu" class="com.capinfo.ems.login.dao.hibernate.Sysmenu" column="FUNCID" outer-join="auto"/>

<property column="SDATE" length="7" name="sdate" type="java.util.Date"/>
<property column="EDATE" length="7" name="edate" type="java.util.Date"/>
</composite-element>

</set>

when i use this set in mapping .
it goes well.
but it can not initialize the class Usertofunc.
follow is exception.

ysuser0_.EMPSEQNO as x0_0_ from CAPBUSS.SYSUSER sysuser0_ where (sysuser0_.EMPID=? )

14:02:58,750 DEBUG BatcherImpl:241 - preparing statement

14:02:59,040 DEBUG IteratorImpl:69 - retrieving next results

14:02:59,180 DEBUG SessionImpl:1950 - loading [com.capinfo.ems.login.dao.hibernate.Sysuser#1]

14:02:59,180 DEBUG SessionImpl:2047 - attempting to resolve [com.capinfo.ems.login.dao.hibernate.Sysuser#1]

14:02:59,200 DEBUG SessionImpl:2080 - object not resolved in any cache [com.capinfo.ems.login.dao.hibernate.Sysuser#1]

14:02:59,200 DEBUG EntityPersister:416 - Materializing entity: [com.capinfo.ems.login.dao.hibernate.Sysuser#1]

14:02:59,210 DEBUG BatcherImpl:196 - about to open: 1 open PreparedStatements, 1 open ResultSets

14:02:59,210 DEBUG SQL:237 - select sysuser0_.EMPSEQNO as EMPSEQNO0_, sysuser0_.EMPID as EMPID0_, sysuser0_.EMPNAME as EMPNAME0_, sysuser0_.PWD as PWD0_, sysuser0_.AVLSDATE as AVLSDATE0_, sysuser0_.AVLEDATE as AVLEDATE0_, sysuser0_.MEMO as MEMO0_, sysuser0_.USERSTATE as USERSTATE0_, sysuser0_.PUBICKEY as PUBICKEY0_, sysuser0_.VALIDTAG as VALIDTAG0_, sysuser0_.LOSSDATE as LOSSDATE0_ from CAPBUSS.SYSUSER sysuser0_ where sysuser0_.EMPSEQNO=?

Hibernate: select sysuser0_.EMPSEQNO as EMPSEQNO0_, sysuser0_.EMPID as EMPID0_, sysuser0_.EMPNAME as EMPNAME0_, sysuser0_.PWD as PWD0_, sysuser0_.AVLSDATE as AVLSDATE0_, sysuser0_.AVLEDATE as AVLEDATE0_, sysuser0_.MEMO as MEMO0_, sysuser0_.USERSTATE as USERSTATE0_, sysuser0_.PUBICKEY as PUBICKEY0_, sysuser0_.VALIDTAG as VALIDTAG0_, sysuser0_.LOSSDATE as LOSSDATE0_ from CAPBUSS.SYSUSER sysuser0_ where sysuser0_.EMPSEQNO=?

14:02:59,220 DEBUG BatcherImpl:241 - preparing statement

14:02:59,230 DEBUG Loader:197 - processing result set

14:02:59,240 DEBUG Loader:405 - result row: 1

14:02:59,270 DEBUG Loader:536 - Initializing object from ResultSet: 1

14:02:59,280 DEBUG Loader:605 - Hydrating entity: com.capinfo.ems.login.dao.hibernate.Sysuser#1

14:02:59,290 DEBUG Loader:226 - done processing result set (1 rows)

14:02:59,350 DEBUG BatcherImpl:203 - done closing: 1 open PreparedStatements, 1 open ResultSets

14:02:59,350 DEBUG BatcherImpl:261 - closing statement

14:02:59,380 DEBUG Loader:239 - total objects hydrated: 1

14:02:59,380 DEBUG SessionImpl:2166 - resolving associations for [com.capinfo.ems.login.dao.hibernate.Sysuser#1]

14:02:59,390 DEBUG SessionImpl:3891 - creating collection wrapper:[com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

14:02:59,390 DEBUG SessionImpl:2190 - done materializing entity [com.capinfo.ems.login.dao.hibernate.Sysuser#1]

14:02:59,400 DEBUG SessionImpl:3082 - initializing non-lazy collections

14:02:59,410 DEBUG IteratorImpl:65 - exhausted results

14:02:59,451 DEBUG IteratorImpl:53 - closing iterator

14:02:59,451 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets

14:02:59,451 DEBUG BatcherImpl:261 - closing statement

14:02:59,461 DEBUG IteratorImpl:92 - returning current results

14:02:59,461 DEBUG JDBCTransaction:59 - commit

14:02:59,471 DEBUG SessionImpl:2210 - flushing session

14:02:59,481 DEBUG SessionImpl:2403 - Flushing entities and processing referenced collections

14:02:59,501 DEBUG SessionImpl:2850 - Collection found: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1], was: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

14:02:59,501 DEBUG SessionImpl:2746 - Processing unreferenced collections

14:02:59,501 DEBUG SessionImpl:2760 - Scheduling collection removes/(re)creates/updates

14:02:59,501 DEBUG SessionImpl:2234 - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects

14:02:59,511 DEBUG SessionImpl:2239 - Flushed: 0 (re)creations, 0 updates, 0 removals to 1 collections

14:02:59,511 DEBUG Printer:75 - listing entities:

14:02:59,711 DEBUG Printer:82 - com.capinfo.ems.login.dao.hibernate.Sysuser{usertofunc=uninitialized, pubickey=0, memo=null, validtag=null, userstate=0, lossdate=null, empname=test, avlsdate=01 四月 2004 00:00:00, empid=1, empseqno=1, avledate=null, pwd=1}

14:02:59,711 DEBUG SessionImpl:2323 - executing flush

14:02:59,711 DEBUG SessionImpl:2790 - post flush

14:02:59,731 DEBUG SessionImpl:561 - transaction completion

14:02:59,741 DEBUG SessionImpl:2210 - flushing session

14:02:59,741 DEBUG SessionImpl:2403 - Flushing entities and processing referenced collections

14:02:59,741 DEBUG SessionImpl:2850 - Collection found: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1], was: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

14:02:59,741 DEBUG SessionImpl:2746 - Processing unreferenced collections

14:02:59,741 DEBUG SessionImpl:2760 - Scheduling collection removes/(re)creates/updates

14:02:59,761 DEBUG SessionImpl:2234 - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects

14:02:59,761 DEBUG SessionImpl:2239 - Flushed: 0 (re)creations, 0 updates, 0 removals to 1 collections

14:02:59,761 DEBUG Printer:75 - listing entities:

14:02:59,761 DEBUG Printer:82 - com.capinfo.ems.login.dao.hibernate.Sysuser{usertofunc=uninitialized, pubickey=0, memo=null, validtag=null, userstate=0, lossdate=null, empname=test, avlsdate=01 四月 2004 00:00:00, empid=1, empseqno=1, avledate=null, pwd=1}

14:02:59,761 DEBUG SessionImpl:2323 - executing flush

14:02:59,761 DEBUG SessionImpl:2790 - post flush

1

14:02:59,771 DEBUG SessionImpl:3218 - initializing collection [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

14:02:59,771 DEBUG SessionImpl:3219 - checking second-level cache

14:02:59,771 DEBUG SessionImpl:3225 - collection not cached

14:02:59,771 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets

14:02:59,771 DEBUG SQL:237 - select usertofunc0_.FUNCID as FUNCID__, usertofunc0_.SDATE as SDATE__, usertofunc0_.EDATE as EDATE__, usertofunc0_.EMPSEQNO as EMPSEQNO__, sysmenu1_.FUNCID as FUNCID0_, sysmenu1_.FUNCNAME as FUNCNAME0_, sysmenu1_.MEMO as MEMO0_ from CAPBUSS.USERTOFUNC usertofunc0_, CAPBUSS.SYSMENU sysmenu1_ where usertofunc0_.EMPSEQNO=? and usertofunc0_.FUNCID=sysmenu1_.FUNCID(+)

Hibernate: select usertofunc0_.FUNCID as FUNCID__, usertofunc0_.SDATE as SDATE__, usertofunc0_.EDATE as EDATE__, usertofunc0_.EMPSEQNO as EMPSEQNO__, sysmenu1_.FUNCID as FUNCID0_, sysmenu1_.FUNCNAME as FUNCNAME0_, sysmenu1_.MEMO as MEMO0_ from CAPBUSS.USERTOFUNC usertofunc0_, CAPBUSS.SYSMENU sysmenu1_ where usertofunc0_.EMPSEQNO=? and usertofunc0_.FUNCID=sysmenu1_.FUNCID(+)

14:02:59,791 DEBUG BatcherImpl:241 - preparing statement

14:02:59,801 DEBUG Loader:327 - result set contains (possibly empty) collection: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

14:02:59,801 DEBUG SessionImpl:2984 - uninitialized collection: initializing

14:02:59,801 DEBUG Loader:197 - processing result set

14:02:59,811 DEBUG JDBCExceptionReporter:36 - SQL Exception

java.sql.SQLException: 无法转换为内部表示

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)

at oracle.jdbc.driver.OracleStatement.getLongValue(OracleStatement.java:4367)

at oracle.jdbc.driver.OracleResultSetImpl.getLong(OracleResultSetImpl.java:529)

at oracle.jdbc.driver.OracleResultSet.getLong(OracleResultSet.java:1540)

at net.sf.hibernate.type.LongType.get(LongType.java:18)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)

at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:352)

at net.sf.hibernate.loader.Loader.doQuery(Loader.java:203)

at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)

at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:69)

at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)

at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)

at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:200)

at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)

at net.sf.hibernate.collection.Set.toString(Set.java:218)

at java.lang.String.valueOf(String.java:2131)

at java.io.PrintStream.print(PrintStream.java:462)

at java.io.PrintStream.println(PrintStream.java:599)

at com.capinfo.ems.login.dao.hibernate.TestSysuser.main(TestSysuser.java:17)

14:03:00,001 WARN JDBCExceptionReporter:38 - SQL Error: 17059, SQLState: null

14:03:00,021 ERROR JDBCExceptionReporter:46 - 无法转换为内部表示

14:03:00,021 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets

14:03:00,021 DEBUG BatcherImpl:261 - closing statement

14:03:00,061 DEBUG JDBCExceptionReporter:36 - SQL Exception

java.sql.SQLException: 无法转换为内部表示

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)

at oracle.jdbc.driver.OracleStatement.getLongValue(OracleStatement.java:4367)

at oracle.jdbc.driver.OracleResultSetImpl.getLong(OracleResultSetImpl.java:529)

at oracle.jdbc.driver.OracleResultSet.getLong(OracleResultSet.java:1540)

at net.sf.hibernate.type.LongType.get(LongType.java:18)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)

at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:352)

at net.sf.hibernate.loader.Loader.doQuery(Loader.java:203)

at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)

at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:69)

at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)

at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)

at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:200)

at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)

at net.sf.hibernate.collection.Set.toString(Set.java:218)

at java.lang.String.valueOf(String.java:2131)

at java.io.PrintStream.print(PrintStream.java:462)

at java.io.PrintStream.println(PrintStream.java:599)

at com.capinfo.ems.login.dao.hibernate.TestSysuser.main(TestSysuser.java:17)

14:03:00,101 WARN JDBCExceptionReporter:38 - SQL Error: 17059, SQLState: null

14:03:00,101 ERROR JDBCExceptionReporter:46 - 无法转换为内部表示

14:03:00,101 ERROR JDBCExceptionReporter:38 - could not initialize collection: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

java.sql.SQLException: 无法转换为内部表示

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)

at oracle.jdbc.driver.OracleStatement.getLongValue(OracleStatement.java:4367)

at oracle.jdbc.driver.OracleResultSetImpl.getLong(OracleResultSetImpl.java:529)

at oracle.jdbc.driver.OracleResultSet.getLong(OracleResultSet.java:1540)

at net.sf.hibernate.type.LongType.get(LongType.java:18)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)

at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:352)

at net.sf.hibernate.loader.Loader.doQuery(Loader.java:203)

at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)

at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:69)

at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)

at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)

at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:200)

at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)

at net.sf.hibernate.collection.Set.toString(Set.java:218)

at java.lang.String.valueOf(String.java:2131)

at java.io.PrintStream.print(PrintStream.java:462)

at java.io.PrintStream.println(PrintStream.java:599)

at com.capinfo.ems.login.dao.hibernate.TestSysuser.main(TestSysuser.java:17)

14:03:00,132 ERROR PersistentCollection:203 - Failed to lazily initialize a collection

net.sf.hibernate.JDBCException: could not initialize collection: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:287)

at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)

at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:200)

at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)

at net.sf.hibernate.collection.Set.toString(Set.java:218)

at java.lang.String.valueOf(String.java:2131)

at java.io.PrintStream.print(PrintStream.java:462)

at java.io.PrintStream.println(PrintStream.java:599)

at com.capinfo.ems.login.dao.hibernate.TestSysuser.main(TestSysuser.java:17)

Caused by: java.sql.SQLException: 无法转换为内部表示

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)

at oracle.jdbc.driver.OracleStatement.getLongValue(OracleStatement.java:4367)

at oracle.jdbc.driver.OracleResultSetImpl.getLong(OracleResultSetImpl.java:529)

at oracle.jdbc.driver.OracleResultSet.getLong(OracleResultSet.java:1540)

at net.sf.hibernate.type.LongType.get(LongType.java:18)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)

at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:352)

at net.sf.hibernate.loader.Loader.doQuery(Loader.java:203)

at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)

at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:69)

at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)

... 8 more

net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection

at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:206)

at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)

at net.sf.hibernate.collection.Set.toString(Set.java:218)

at java.lang.String.valueOf(String.java:2131)

at java.io.PrintStream.print(PrintStream.java:462)

at java.io.PrintStream.println(PrintStream.java:599)

at com.capinfo.ems.login.dao.hibernate.TestSysuser.main(TestSysuser.java:17)

Caused by: net.sf.hibernate.JDBCException: could not initialize collection: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:287)

at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)

at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:200)

... 6 more

Caused by: java.sql.SQLException: 无法转换为内部表示

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)

at oracle.jdbc.driver.OracleStatement.getLongValue(OracleStatement.java:4367)

at oracle.jdbc.driver.OracleResultSetImpl.getLong(OracleResultSetImpl.java:529)

at oracle.jdbc.driver.OracleResultSet.getLong(OracleResultSet.java:1540)

at net.sf.hibernate.type.LongType.get(LongType.java:18)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)

at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:352)

at net.sf.hibernate.loader.Loader.doQuery(Loader.java:203)

at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)

at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:69)

at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 30, 2004 3:44 am 
Newbie

Joined: Thu Apr 29, 2004 11:15 pm
Posts: 8
now i resolve the question .but i meet the exception such as:

15:40:16,394 DEBUG SessionImpl:3218 - initializing collection [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

15:40:16,394 DEBUG SessionImpl:3219 - checking second-level cache

15:40:16,394 DEBUG SessionImpl:3225 - collection not cached

15:40:16,394 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets

15:40:16,404 DEBUG SQL:237 - select usertofunc0_.FUNCID as FUNCID__, usertofunc0_.SDATE as SDATE__, usertofunc0_.EDATE as EDATE__, usertofunc0_.EMPSEQNO as EMPSEQNO__, sysmenu1_.FUNCID as FUNCID0_, sysmenu1_.FUNCNAME as FUNCNAME0_, sysmenu1_.MEMO as MEMO0_ from CAPBUSS.USERTOFUNC usertofunc0_, CAPBUSS.SYSMENU sysmenu1_ where usertofunc0_.EMPSEQNO=? and usertofunc0_.FUNCID=sysmenu1_.FUNCID(+)

Hibernate: select usertofunc0_.FUNCID as FUNCID__, usertofunc0_.SDATE as SDATE__, usertofunc0_.EDATE as EDATE__, usertofunc0_.EMPSEQNO as EMPSEQNO__, sysmenu1_.FUNCID as FUNCID0_, sysmenu1_.FUNCNAME as FUNCNAME0_, sysmenu1_.MEMO as MEMO0_ from CAPBUSS.USERTOFUNC usertofunc0_, CAPBUSS.SYSMENU sysmenu1_ where usertofunc0_.EMPSEQNO=? and usertofunc0_.FUNCID=sysmenu1_.FUNCID(+)

15:40:16,404 DEBUG BatcherImpl:241 - preparing statement

15:40:16,414 DEBUG Loader:327 - result set contains (possibly empty) collection: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

15:40:16,414 DEBUG SessionImpl:2984 - uninitialized collection: initializing

15:40:16,424 DEBUG Loader:197 - processing result set

15:40:16,424 DEBUG Loader:405 - result row: B120

15:40:16,424 DEBUG Loader:536 - Initializing object from ResultSet: B120

15:40:16,434 DEBUG Loader:605 - Hydrating entity: com.capinfo.ems.login.dao.hibernate.Sysmenu#B120

15:40:16,434 DEBUG Loader:292 - found row of collection: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

15:40:16,434 DEBUG SessionImpl:3007 - reading row

15:40:16,434 DEBUG SessionImpl:1950 - loading [com.capinfo.ems.login.dao.hibernate.Sysmenu#B120]

15:40:16,444 DEBUG SessionImpl:2047 - attempting to resolve [com.capinfo.ems.login.dao.hibernate.Sysmenu#B120]

15:40:16,444 DEBUG SessionImpl:2063 - resolved object in session cache [com.capinfo.ems.login.dao.hibernate.Sysmenu#B120]

15:40:16,444 DEBUG Loader:405 - result row: B130

15:40:16,514 DEBUG Loader:536 - Initializing object from ResultSet: B130

15:40:16,524 DEBUG Loader:605 - Hydrating entity: com.capinfo.ems.login.dao.hibernate.Sysmenu#B130

15:40:16,524 DEBUG Loader:292 - found row of collection: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

15:40:16,524 DEBUG SessionImpl:3007 - reading row

15:40:16,524 DEBUG SessionImpl:1950 - loading [com.capinfo.ems.login.dao.hibernate.Sysmenu#B130]

15:40:16,534 DEBUG SessionImpl:2047 - attempting to resolve [com.capinfo.ems.login.dao.hibernate.Sysmenu#B130]

15:40:16,534 DEBUG SessionImpl:2063 - resolved object in session cache [com.capinfo.ems.login.dao.hibernate.Sysmenu#B130]

15:40:16,534 DEBUG Loader:405 - result row: B210

15:40:16,534 DEBUG Loader:536 - Initializing object from ResultSet: B210

15:40:16,544 DEBUG Loader:605 - Hydrating entity: com.capinfo.ems.login.dao.hibernate.Sysmenu#B210

15:40:16,544 DEBUG Loader:292 - found row of collection: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

15:40:16,544 DEBUG SessionImpl:3007 - reading row

15:40:16,544 DEBUG SessionImpl:1950 - loading [com.capinfo.ems.login.dao.hibernate.Sysmenu#B210]

15:40:16,544 DEBUG SessionImpl:2047 - attempting to resolve [com.capinfo.ems.login.dao.hibernate.Sysmenu#B210]

15:40:16,594 DEBUG SessionImpl:2063 - resolved object in session cache [com.capinfo.ems.login.dao.hibernate.Sysmenu#B210]

15:40:16,594 DEBUG Loader:405 - result row: B430

15:40:16,604 DEBUG Loader:536 - Initializing object from ResultSet: B430

15:40:16,604 DEBUG Loader:605 - Hydrating entity: com.capinfo.ems.login.dao.hibernate.Sysmenu#B430

15:40:16,604 DEBUG Loader:292 - found row of collection: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

15:40:16,614 DEBUG SessionImpl:3007 - reading row

15:40:16,614 DEBUG SessionImpl:1950 - loading [com.capinfo.ems.login.dao.hibernate.Sysmenu#B430]

15:40:16,614 DEBUG SessionImpl:2047 - attempting to resolve [com.capinfo.ems.login.dao.hibernate.Sysmenu#B430]

15:40:16,614 DEBUG SessionImpl:2063 - resolved object in session cache [com.capinfo.ems.login.dao.hibernate.Sysmenu#B430]

15:40:16,614 DEBUG Loader:405 - result row: B520

15:40:16,614 DEBUG Loader:536 - Initializing object from ResultSet: B520

15:40:16,614 DEBUG Loader:605 - Hydrating entity: com.capinfo.ems.login.dao.hibernate.Sysmenu#B520

15:40:16,624 DEBUG Loader:292 - found row of collection: [com.capinfo.ems.login.dao.hibernate.Sysuser.usertofunc#1]

15:40:16,624 DEBUG SessionImpl:3007 - reading row

15:40:16,624 DEBUG SessionImpl:1950 - loading [com.capinfo.ems.login.dao.hibernate.Sysmenu#B520]

15:40:16,624 DEBUG SessionImpl:2047 - attempting to resolve [com.capinfo.ems.login.dao.hibernate.Sysmenu#B520]

15:40:16,624 DEBUG SessionImpl:2063 - resolved object in session cache [com.capinfo.ems.login.dao.hibernate.Sysmenu#B520]

15:40:16,634 DEBUG Loader:226 - done processing result set (5 rows)

15:40:16,634 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets

15:40:16,634 DEBUG BatcherImpl:261 - closing statement

15:40:16,634 DEBUG Loader:239 - total objects hydrated: 5

15:40:16,634 DEBUG SessionImpl:2166 - resolving associations for [com.capinfo.ems.login.dao.hibernate.Sysmenu#B120]

15:40:16,694 DEBUG SessionImpl:2190 - done materializing entity [com.capinfo.ems.login.dao.hibernate.Sysmenu#B120]

15:40:16,704 DEBUG SessionImpl:2166 - resolving associations for [com.capinfo.ems.login.dao.hibernate.Sysmenu#B130]

15:40:16,704 DEBUG SessionImpl:2190 - done materializing entity [com.capinfo.ems.login.dao.hibernate.Sysmenu#B130]

15:40:16,704 DEBUG SessionImpl:2166 - resolving associations for [com.capinfo.ems.login.dao.hibernate.Sysmenu#B210]

15:40:16,704 DEBUG SessionImpl:2190 - done materializing entity [com.capinfo.ems.login.dao.hibernate.Sysmenu#B210]

15:40:16,704 DEBUG SessionImpl:2166 - resolving associations for [com.capinfo.ems.login.dao.hibernate.Sysmenu#B430]

15:40:16,704 DEBUG SessionImpl:2190 - done materializing entity [com.capinfo.ems.login.dao.hibernate.Sysmenu#B430]

15:40:16,714 DEBUG SessionImpl:2166 - resolving associations for [com.capinfo.ems.login.dao.hibernate.Sysmenu#B520]

15:40:16,714 DEBUG SessionImpl:2190 - done materializing entity [com.capinfo.ems.login.dao.hibernate.Sysmenu#B520]

15:40:16,714 DEBUG SessionImpl:3043 - 1 collections were found in result set

15:40:16,724 ERROR PersistentCollection:203 - Failed to lazily initialize a collection

java.lang.NullPointerException

at com.capinfo.ems.login.dao.hibernate.Usertofunc.hashCode(Usertofunc.java:71)

at java.util.HashMap.hash(HashMap.java:261)

at java.util.HashMap.put(HashMap.java:379)

at java.util.HashSet.add(HashSet.java:192)

at java.util.AbstractCollection.addAll(AbstractCollection.java:319)

at net.sf.hibernate.collection.Set.endRead(Set.java:245)

at net.sf.hibernate.impl.SessionImpl.endLoadingCollections(SessionImpl.java:3048)

at net.sf.hibernate.impl.SessionImpl.endLoadingCollections(SessionImpl.java:3035)

at net.sf.hibernate.loader.Loader.doQuery(Loader.java:243)

at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)

at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:69)

at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)

at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)

at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:200)

at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)

at net.sf.hibernate.collection.Set.toString(Set.java:218)

at java.lang.String.valueOf(String.java:2131)

at java.io.PrintStream.print(PrintStream.java:462)

at java.io.PrintStream.println(PrintStream.java:599)

at com.capinfo.ems.login.dao.hibernate.TestSysuser.main(TestSysuser.java:20)

net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection

at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:206)

at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)

at net.sf.hibernate.collection.Set.toString(Set.java:218)

at java.lang.String.valueOf(String.java:2131)

at java.io.PrintStream.print(PrintStream.java:462)

at java.io.PrintStream.println(PrintStream.java:599)

at com.capinfo.ems.login.dao.hibernate.TestSysuser.main(TestSysuser.java:20)

Caused by: java.lang.NullPointerException

at com.capinfo.ems.login.dao.hibernate.Usertofunc.hashCode(Usertofunc.java:71)

at java.util.HashMap.hash(HashMap.java:261)

at java.util.HashMap.put(HashMap.java:379)

at java.util.HashSet.add(HashSet.java:192)

at java.util.AbstractCollection.addAll(AbstractCollection.java:319)

at net.sf.hibernate.collection.Set.endRead(Set.java:245)

at net.sf.hibernate.impl.SessionImpl.endLoadingCollections(SessionImpl.java:3048)

at net.sf.hibernate.impl.SessionImpl.endLoadingCollections(SessionImpl.java:3035)

at net.sf.hibernate.loader.Loader.doQuery(Loader.java:243)

at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)

at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)

at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:69)

at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)

at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)

at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:200)

... 6 more

Exception in thread "main"

and my class is .

public class Usertofunc implements Serializable{

private long empseqno;
private String funcid;
private Date sdate;
private Date edate;

//private Sysuser sysuser;
private Sysmenu sysmenu;
public long getEmpseqno() {
return empseqno;
}

public Date getSdate() {
return sdate;
}
/**
public Sysuser getSysuser() {
return sysuser;
}
*/
public String getFuncid() {
return funcid;
}

public Date getEdate() {
return edate;
}

public void setSysmenu(Sysmenu sysmenu) {
this.sysmenu = sysmenu;
}

public void setEmpseqno(long empseqno) {
this.empseqno = empseqno;
}

public void setSdate(Date sdate) {
this.sdate = sdate;
}
/**
public void setSysuser(Sysuser sysuser) {
this.sysuser = sysuser;
}
*/
public void setFuncid(String funcid) {
this.funcid = funcid;
}

public void setEdate(Date edate) {
this.edate = edate;
}

public Sysmenu getSysmenu() {
return sysmenu;
}

public Usertofunc(Sysmenu sysmenu) {
this.sysmenu=sysmenu;
}
public boolean equals(Object obj) {
Usertofunc uf=(Usertofunc)obj;
return this.empseqno==uf.getEmpseqno()&& this.funcid.equals(uf.getFuncid());
}
public int hashCode() {
return new Long(this.empseqno).hashCode()+this.funcid.hashCode();
}

public String toString() {
return "[usertofunc]"+"the funcid is: "+this.getFuncid();
}
public Usertofunc() {

}
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 30, 2004 1:32 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
empseqno of funcid is null.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 01, 2004 5:28 am 
Newbie

Joined: Thu Apr 29, 2004 11:15 pm
Posts: 8
emmanuel wrote:
empseqno of funcid is null.


yes i know that property is null,so the collection is empty.

but i can get the class sysuser object through empseqno=1.
when i invoke the code:
Set s=Sysuser.getUserfofunc();

i get the no exception but the set has five object but the field
empseqno=0 and the funcid=null.
but in my talbe it has data by pk & fk association.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.