I use Hibernate 2
I have a little problem that i can't find solution:
I have a many-to-many collection between STUDENT and EXAM, Stundent.booking is list of exam which are booked from student, and Exam.booked, list of student that are booked to this exam.
When I update the two object at run-time, the collection are updated but, when I save two object on MySQL Server 4.1, with session.saveOrUpdate( ... ), changes aren't applied.
Hibernate log shows the relationof collections are identificated like nonlazy-collection, now, how I do to resolve this conflict?
I use XDoclet to generate mapping.xml so i write the tags insert into the class STUDENT and EXAM:
public class StudentBO{
.....
private List bookings;
/**
* @hibernate.bag name="bookings" table="booking" cascade="save-update" lazy="true"
* @hibernate.collection-key column="student"
* @hibernate.collection-many-to-many class="org.equinox.model.bo.ExamBO" column="exam"
*/
public List getBookings() {
return bookings;
}
...
}
public class ExamBO{
....
private List booked;
/**
* @hibernate.bag name="booked" table="booking"
* cascade="save-update" lazy="true" inverse="true"
* @hibernate.collection-key column="exam"
* @hibernate.collection-many-to-many
* class="org.equinox.model.bo.StudentBO" column="student"
*/
public List getBooked() {
return booked;
}
.....
}
[equinox] DEBUG [http-8080-Processor23] SessionImpl.<init>(542) | opened session
[equinox] DEBUG [http-8080-Processor23] ModuleUtils.getModuleName(169) | Get module name for path /bookExam.do
[equinox] DEBUG [http-8080-Processor23] ModuleUtils.getModuleName(193) | Module name found: default
[equinox] DEBUG [http-8080-Processor23] RequestProcessor.processActionCreate(257) | Looking for Action instance for class org.equinox.web.action.BookedExamAction
[equinox] DEBUG [http-8080-Processor23] RequestProcessor.processActionCreate(278) | Creating new Action instance
[equinox] DEBUG [http-8080-Processor23] JDBCTransaction.begin(37) | begin
[equinox] DEBUG [http-8080-Processor23] JDBCTransaction.begin(41) | current autocommit status:true
[equinox] DEBUG [http-8080-Processor23] JDBCTransaction.begin(43) | disabling autocommit
[equinox] DEBUG [http-8080-Processor23] SessionImpl.doLoadByClass(1975) | loading [org.equinox.model.bo.ExamBO#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.doLoad(2072) | attempting to resolve [org.equinox.model.bo.ExamBO#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.doLoad(2105) | object not resolved in any cache [org.equinox.model.bo.ExamBO#3]
[equinox] DEBUG [http-8080-Processor23] EntityPersister.load(416) | Materializing entity: [org.equinox.model.bo.ExamBO#3]
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.logOpenPreparedStatement(196) | about to open: 0 open PreparedStatements, 0 open ResultSets
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.getPreparedStatement(237) | select exambo0_.oid as oid0_, exambo0_.course as course0_, exambo0_.examdate as examdate0_, exambo0_.examloc as examloc0_, exambo0_.sexamdate as sexamdate0_, exambo0_.sexamloc as sexamloc0_, exambo0_.notes as notes0_ from exam exambo0_ where exambo0_.oid=?
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.getPreparedStatement(241) | preparing statement
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeSet(46) | binding '3' to parameter: 1
[equinox] DEBUG [http-8080-Processor23] Loader.doQuery(197) | processing result set
[equinox] DEBUG [http-8080-Processor23] Loader.getRow(405) | result row: 3
[equinox] DEBUG [http-8080-Processor23] Loader.loadFromResultSet(536) | Initializing object from ResultSet: 3
[equinox] DEBUG [http-8080-Processor23] Loader.hydrate(605) | Hydrating entity: org.equinox.model.bo.ExamBO#3
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning '2' as column: course0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning '23 July 2004' as column: examdate0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning 'Aula T8' as column: examloc0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning '30 July 2004' as column: sexamdate0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning 'Aula 19' as column: sexamloc0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning 'Venire Gi? Studiati' as column: notes0_
[equinox] DEBUG [http-8080-Processor23] Loader.doQuery(226) | done processing result set (1 rows)
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.logClosePreparedStatement(203) | done closing: 0 open PreparedStatements, 0 open ResultSets
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.closePreparedStatement(261) | closing statement
[equinox] DEBUG [http-8080-Processor23] Loader.doQuery(239) | total objects hydrated: 1
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeEntity(2191) | resolving associations for [org.equinox.model.bo.ExamBO#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.doLoadByClass(1975) | loading [org.equinox.model.bo.CourseBO#2]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.getCollection(3924) | creating collection wrapper:[org.equinox.model.bo.ExamBO.booked#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeEntity(2215) | done materializing entity [org.equinox.model.bo.ExamBO#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeNonLazyCollections(3107) | initializing non-lazy collections
[equinox] DEBUG [http-8080-Processor23] ServiceManagerImpl.bookExam(522) | ------------------- Aggiungo Esame&Studente alleliste concatenate---------------------
[equinox] DEBUG [http-8080-Processor23] SessionImpl.doLoadByClass(1975) | loading [org.equinox.model.bo.StudentBO#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.doLoad(2072) | attempting to resolve [org.equinox.model.bo.StudentBO#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.doLoad(2105) | object not resolved in any cache [org.equinox.model.bo.StudentBO#3]
[equinox] DEBUG [http-8080-Processor23] EntityPersister.load(416) | Materializing entity: [org.equinox.model.bo.StudentBO#3]
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.logOpenPreparedStatement(196) | about to open: 0 open PreparedStatements, 0 open ResultSets
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.getPreparedStatement(237) | select studentbo0_.oid as oid0_, studentbo0_.id as id0_, studentbo0_.email as email0_, studentbo0_.tutor as tutor0_, studentbo0_.stage as stage0_, studentbo0_.usernameas username0_, studentbo0_.pwd as pwd0_, studentbo0_.name as name0_, studentbo0_.surname as surname0_, studentbo0_.role as role0_, studentbo0_.active as active0_ from user studentbo0_ where studentbo0_.oid=?
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.getPreparedStatement(241) | preparing statement
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeSet(46) | binding '3' to parameter: 1
[equinox] DEBUG [http-8080-Processor23] Loader.doQuery(197) | processing result set
[equinox] DEBUG [http-8080-Processor23] Loader.getRow(405) | result row: 3
[equinox] DEBUG [http-8080-Processor23] Loader.loadFromResultSet(536) | Initializing object from ResultSet: 3
[equinox] DEBUG [http-8080-Processor23] Loader.hydrate(605) | Hydrating entity: org.equinox.model.bo.StudentBO#3
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning '3' as column: id0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning 'rossi@informatica.uniroma2.it' as column:email0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning '1' as column: tutor0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning '1' as column: stage0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning 'rossi' as column: username0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning 'e0591aab15eb15951af97dd227f5302d' as column: pwd0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning 'luca' as column: name0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning 'rossi' as column: surname0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning 'studente' as column: role0_
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeGet(68) | returning 'true' as column: active0_
[equinox] DEBUG [http-8080-Processor23] Loader.doQuery(226) | done processing result set (1 rows)
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.logClosePreparedStatement(203) | done closing: 0 open PreparedStatements, 0 open ResultSets
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.closePreparedStatement(261) | closing statement
[equinox] DEBUG [http-8080-Processor23] Loader.doQuery(239) | total objects hydrated: 1
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeEntity(2191) | resolving associations for [org.equinox.model.bo.StudentBO#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.doLoadByClass(1975) | loading [org.equinox.model.bo.TeacherBO#1]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.doLoadByClass(1975) | loading [org.equinox.model.bo.StageBO#1]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.getCollection(3924) | creating collection wrapper:[org.equinox.model.bo.StudentBO.bookings#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.getCollection(3924) | creating collection wrapper:[org.equinox.model.bo.UserBO.moderated#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.getCollection(3924) | creating collection wrapper:[org.equinox.model.bo.UserBO.enabledServices#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeEntity(2215) | done materializing entity [org.equinox.model.bo.StudentBO#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeNonLazyCollections(3107) | initializing non-lazy collections
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeCollection(3251) | initializing collection [org.equinox.model.bo.ExamBO.booked#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeCollection(3252) | checking second-level cache
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeCollection(3258) | collection not cached
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.logOpenPreparedStatement(196) | about to open: 0 open PreparedStatements, 0 open ResultSets
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.getPreparedStatement(237) | select booked0_.student as student__, booked0_.exam as exam__ from booking booked0_ where booked0_.exam=?
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.getPreparedStatement(241) | preparing statement
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeSet(46) | binding '3' to parameter: 1
[equinox] DEBUG [http-8080-Processor23] Loader.handleEmptyCollections(327) | result set contains (possibly empty) collection: [org.equinox.model.bo.ExamBO.booked#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.getLoadingCollection(3009) | uninitialized collection: initializing
[equinox] DEBUG [http-8080-Processor23] Loader.doQuery(197) | processing result set
[equinox] DEBUG [http-8080-Processor23] Loader.doQuery(226) | done processing result set (0 rows)
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.logClosePreparedStatement(203) | done closing: 0 open PreparedStatements, 0 open ResultSets
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.closePreparedStatement(261) | closing statement
[equinox] DEBUG [http-8080-Processor23] SessionImpl.endLoadingCollections(3068) | 1 collections were found in result set
[equinox] DEBUG [http-8080-Processor23] SessionImpl.endLoadingCollections(3086) | collection fully initialized: [org.equinox.model.bo.ExamBO.booked#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.endLoadingCollections(3089) | 1 collections initialized
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeNonLazyCollections(3107) | initializing non-lazy collections
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeCollection(3260) | collection initialized
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeCollection(3251) | initializing collection [org.equinox.model.bo.StudentBO.bookings#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeCollection(3252) | checking second-level cache
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeCollection(3258) | collection not cached
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.logOpenPreparedStatement(196) | about to open: 0 open PreparedStatements, 0 open ResultSets
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.getPreparedStatement(237) | select bookings0_.exam as exam__, bookings0_.student as student__ from booking bookings0_ where bookings0_.student=?
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.getPreparedStatement(241) | preparing statement
[equinox] DEBUG [http-8080-Processor23] NullableType.nullSafeSet(46) | binding '3' to parameter: 1
[equinox] DEBUG [http-8080-Processor23] Loader.handleEmptyCollections(327) | result set contains (possibly empty) collection: [org.equinox.model.bo.StudentBO.bookings#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.getLoadingCollection(3009) | uninitialized collection: initializing
[equinox] DEBUG [http-8080-Processor23] Loader.doQuery(197) | processing result set
[equinox] DEBUG [http-8080-Processor23] Loader.doQuery(226) | done processing result set (0 rows)
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.logClosePreparedStatement(203) | done closing: 0 open PreparedStatements, 0 open ResultSets
[equinox] DEBUG [http-8080-Processor23] BatcherImpl.closePreparedStatement(261) | closing statement
[equinox] DEBUG [http-8080-Processor23] SessionImpl.endLoadingCollections(3068) | 1 collections were found in result set
[equinox] DEBUG [http-8080-Processor23] SessionImpl.endLoadingCollections(3086) | collection fully initialized: [org.equinox.model.bo.StudentBO.bookings#3]
[equinox] DEBUG [http-8080-Processor23] SessionImpl.endLoadingCollections(3089) | 1 collections initialized
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeNonLazyCollections(3107) | initializing non-lazy collections
[equinox] DEBUG [http-8080-Processor23] SessionImpl.initializeCollection(3260) | collection initialized
[equinox] DEBUG [http-8080-Processor23] ServiceManagerImpl.bookExam(526) | --------------------- Salvo ExamBO e StudentBO --------------------
[equinox] DEBUG [http-8080-Processor23] SessionImpl.saveOrUpdate(1364) | saveOrUpdate() persistent instance
[equinox] DEBUG [http-8080-Processor23] JDBCTransaction.commit(59) | commit
[equinox] DEBUG [http-8080-Processor23] SessionImpl.afterTransactionCompletion(572) | transaction completion
[equinox] DEBUG [http-8080-Processor23] JDBCTransaction.toggleAutoCommit(103) | re-enabling autocommit
[equinox] DEBUG [http-8080-Processor23] TilesRequestProcessor.processForwardConfig(291) | processForwardConfig(.result, false)
[equinox] DEBUG [http-8080-Processor23] TilesRequestProcessor.processTilesDefinition(231) | uri=/layouts/equinoxLayout.jsp doInclude=false
[equinox] DEBUG [http-8080-Processor23] InsertTag$InsertHandler.doEndTag(861) | insert page='/common/equinoxHeader.jsp'.
[equinox] DEBUG [http-8080-Processor23] InsertTag$InsertHandler.doEndTag(861) | insert page='/common/equinoxMenu.jsp'.
[equinox] DEBUG [http-8080-Processor23] InsertTag$InsertHandler.doEndTag(861) | insert page='/WEB-INF/pages/result.jsp'.
[equinox] DEBUG [http-8080-Processor23] PropertyMessageResources.getMessage(134) | getMessage(it,booking.exam)
[equinox] DEBUG [http-8080-Processor23] PropertyMessageResources.loadLocale(226) | loadLocale(it)
[equinox] DEBUG [http-8080-Processor23] PropertyMessageResources.loadLocale(226) | loadLocale(en_US)
[equinox] DEBUG [http-8080-Processor23] PropertyMessageResources.loadLocale(226) | loadLocale()
[equinox] DEBUG [http-8080-Processor23] InsertTag$InsertHandler.doEndTag(861) | insert page='/common/userCounter.jsp'.
[equinox] DEBUG [http-8080-Processor23] InsertTag$InsertHandler.doEndTag(861) | insert page='/common/equinoxRightMenu.jsp'.
[equinox] DEBUG [http-8080-Processor23] InsertTag$InsertHandler.doEndTag(861) | insert page='/WEB-INF/pages/equinoxNews.jsp'.
[equinox] DEBUG [http-8080-Processor23] InsertTag$InsertHandler.doEndTag(861) | insert page='/common/equinoxLogin.jsp'.
[equinox] DEBUG [http-8080-Processor23] InsertTag$InsertHandler.doEndTag(861) | insert page='/common/equinoxReservedMenu.jsp'.
[equinox] DEBUG [http-8080-Processor23] InsertTag$InsertHandler.doEndTag(861) | insert page='/common/equinoxOther.jsp'.
[equinox] DEBUG [http-8080-Processor23] InsertTag$InsertHandler.doEndTag(861) | insert page='/common/equinoxFooter.jsp'.
[equinox] DEBUG [http-8080-Processor23] TilesRequestProcessor.processForwardConfig(305) | '.result' - processed as definition
[equinox] DEBUG [http-8080-Processor23] SessionImpl.close(560) | closing session
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: