Hello world,
Got it to work - my conclusions :
1) You still have to fully map the parent object in the child object; i thought this would not be necessary/allowed, because getting/setting the parent in the child object has no effect and Hibernate knows from the <List> mapping which column to set as foreign key.
2) You still have to fully map the index field in the child object; i thought this would not be necessary/allowed, because it is determined by the order of the List accessible from the parent.
So I changed my child object adding the following :
public class AllocationDay {
private Long allocationDayId;
private Integer weekday = null;
+ getters & setters
........
}
Ok so far.
Next problem is that in my DB, there was a NOT-NULL constraint for DayOfWeek (the index column) and AllocationId (the parent object) in the child table AllocationDays.... I added the NOT-NULL attribute for the mappings of AllocationId and DayOfWeek but the delete strategy of Hibernate seems to be:
-- first disassociate the children from the parent (update to NULL for index+parent columns)
-- next delete the children
So i HAVE TO remove the NOT-NULL constraints - right ?? Any suggestions ?
Thx,
Koen
Here's the SQL for the create - and delete again - cylce :
Hibernate: insert into capacity.dbo.allocation (version, accountid, allocatedFrom, allocatedUntil, creationDt, destinationId, goodsdescriptionId, originId, reference, remark, scheduledFrom, scheduledMovementNr, scheduledUntil, ScheduledVehicleTypeId, username, volumeUnitId, weightUnitId) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: select @@identity
Hibernate: insert into capacity.dbo.AllocationDays (version, dayOfWeek, maxVolume, maxWeight, sta, std, allocationId) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select @@identity
Hibernate: insert into capacity.dbo.AllocationDays (version, dayOfWeek, maxVolume, maxWeight, sta, std, allocationId) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select @@identity
Hibernate: insert into capacity.dbo.AllocationDays (version, dayOfWeek, maxVolume, maxWeight, sta, std, allocationId) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select @@identity
Hibernate: insert into capacity.dbo.AllocationDays (version, dayOfWeek, maxVolume, maxWeight, sta, std, allocationId) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select @@identity
Hibernate: insert into capacity.dbo.AllocationDays (version, dayOfWeek, maxVolume, maxWeight, sta, std, allocationId) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select @@identity
Hibernate: insert into capacity.dbo.AllocationDays (version, dayOfWeek, maxVolume, maxWeight, sta, std, allocationId) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select @@identity
Hibernate: insert into capacity.dbo.AllocationDays (version, dayOfWeek, maxVolume, maxWeight, sta, std, allocationId) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select @@identity
Hibernate: update capacity.dbo.AllocationDays set allocationId=?, dayOfWeek=? where allocationDayId=?
Hibernate: insert into capacity.dbo.allocationProducts (allocationId, productId) values (?, ?)
Hibernate: select allocati0_.allocationId as allocationId, allocati0_.version as version, allocati0_.accountid as accountid, allocati0_.allocatedFrom as allocate4_, allocati0_.allocatedUntil as allocate5_, allocati0_.creationDt as creationDt, allocati0_.destinationId as destinat7_, allocati0_.goodsdescriptionId as goodsdes8_, allocati0_.originId as originId, allocati0_.reference as reference, allocati0_.remark as remark, allocati0_.scheduledFrom as schedul12_, allocati0_.scheduledMovementNr as schedul13_, allocati0_.scheduledUntil as schedul14_, allocati0_.ScheduledVehicleTypeId as Schedul15_, allocati0_.username as username, allocati0_.volumeUnitId as volumeU17_, allocati0_.weightUnitId as weightU18_ from capacity.dbo.allocation allocati0_ where (allocati0_.reference='TESTALLOCATION:1073660103484' )
Hibernate: select allocati0_.allocationId as allocationId, allocati0_.version as version, allocati0_.accountid as accountid, allocati0_.allocatedFrom as allocate4_, allocati0_.allocatedUntil as allocate5_, allocati0_.creationDt as creationDt, allocati0_.destinationId as destinat7_, allocati0_.goodsdescriptionId as goodsdes8_, allocati0_.originId as originId, allocati0_.reference as reference, allocati0_.remark as remark, allocati0_.scheduledFrom as schedul12_, allocati0_.scheduledMovementNr as schedul13_, allocati0_.scheduledUntil as schedul14_, allocati0_.ScheduledVehicleTypeId as Schedul15_, allocati0_.username as username, allocati0_.volumeUnitId as volumeU17_, allocati0_.weightUnitId as weightU18_ from capacity.dbo.allocation allocati0_ where (allocati0_.reference='TESTALLOCATION:1073660103484' )
Hibernate: select allocati0_.allocationId as allocationId, allocati0_.version as version, allocati0_.accountid as accountid, allocati0_.allocatedFrom as allocate4_, allocati0_.allocatedUntil as allocate5_, allocati0_.creationDt as creationDt, allocati0_.destinationId as destinat7_, allocati0_.goodsdescriptionId as goodsdes8_, allocati0_.originId as originId, allocati0_.reference as reference, allocati0_.remark as remark, allocati0_.scheduledFrom as schedul12_, allocati0_.scheduledMovementNr as schedul13_, allocati0_.scheduledUntil as schedul14_, allocati0_.ScheduledVehicleTypeId as Schedul15_, allocati0_.username as username, allocati0_.volumeUnitId as volumeU17_, allocati0_.weightUnitId as weightU18_ from capacity.dbo.allocation allocati0_ where (allocati0_.reference='TESTALLOCATION:1073660103484' )
Hibernate: select allocati0_.allocationId as allocationId, allocati0_.version as version, allocati0_.accountid as accountid, allocati0_.allocatedFrom as allocate4_, allocati0_.allocatedUntil as allocate5_, allocati0_.creationDt as creationDt, allocati0_.destinationId as destinat7_, allocati0_.goodsdescriptionId as goodsdes8_, allocati0_.originId as originId, allocati0_.reference as reference, allocati0_.remark as remark, allocati0_.scheduledFrom as schedul12_, allocati0_.scheduledMovementNr as schedul13_, allocati0_.scheduledUntil as schedul14_, allocati0_.ScheduledVehicleTypeId as Schedul15_, allocati0_.username as username, allocati0_.volumeUnitId as volumeU17_, allocati0_.weightUnitId as weightU18_ from capacity.dbo.allocation allocati0_ where (allocati0_.reference='TESTALLOCATION:1073660103484' )
Hibernate: select allocati0_.allocationId as allocationId, allocati0_.version as version, allocati0_.accountid as accountid, allocati0_.allocatedFrom as allocate4_, allocati0_.allocatedUntil as allocate5_, allocati0_.creationDt as creationDt, allocati0_.destinationId as destinat7_, allocati0_.goodsdescriptionId as goodsdes8_, allocati0_.originId as originId, allocati0_.reference as reference, allocati0_.remark as remark, allocati0_.scheduledFrom as schedul12_, allocati0_.scheduledMovementNr as schedul13_, allocati0_.scheduledUntil as schedul14_, allocati0_.ScheduledVehicleTypeId as Schedul15_, allocati0_.username as username, allocati0_.volumeUnitId as volumeU17_, allocati0_.weightUnitId as weightU18_ from capacity.dbo.allocation allocati0_ where (allocati0_.allocationId=109 )
Hibernate: select allocati0_.allocationDayId as allocati1___, allocati0_.dayOfWeek as dayOfWeek__, allocati0_.allocationDayId as allocationDayId, allocati0_.version as version, allocati0_.dayOfWeek as dayOfWeek, allocati0_.maxVolume as maxVolume, allocati0_.maxWeight as maxWeight, allocati0_.sta as sta, allocati0_.std as std, allocati0_.allocationId as allocati8_ from capacity.dbo.AllocationDays allocati0_ where allocati0_.allocationId=?
Hibernate: update capacity.dbo.AllocationDays set allocationId=null, dayOfWeek=null where allocationId=?
Hibernate: delete from capacity.dbo.allocationProducts where allocationId=?
Hibernate: delete from capacity.dbo.AllocationDays where allocationDayId=? and version=?
Hibernate: delete from capacity.dbo.AllocationDays where allocationDayId=? and version=?
Hibernate: delete from capacity.dbo.AllocationDays where allocationDayId=? and version=?
Hibernate: delete from capacity.dbo.AllocationDays where allocationDayId=? and version=?
Hibernate: delete from capacity.dbo.AllocationDays where allocationDayId=? and version=?
Hibernate: delete from capacity.dbo.AllocationDays where allocationDayId=? and version=?
Hibernate: delete from capacity.dbo.AllocationDays where allocationDayId=? and version=?
Hibernate: delete from capacity.dbo.allocation where allocationId=? and version=?
_________________ Koen Maes
Leuven, Belgium
|