Forgot I should post an example of what i'm talking about
Code:
@Entity
@Table(name="TEST_FIRST")
public class First implements Serializable {
@Id
@GeneratedValue(generator = "idGenerator")
@GenericGenerator( name = "idGenerator",
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
parameters = {
@Parameter(name = "force_table_use", value = "true")
}
)
private Long id;
@OneToOne(cascade = CascadeType.ALL, optional = false , fetch = FetchType.LAZY, mappedBy="first")
@PrimaryKeyJoinColumn
private Second second;
....
}
Code:
@Entity
@Table(name="TEST_SECOND")
public class Second implements Serializable {
@Id
@GeneratedValue(generator = "secondFKeyGenerator")
@GenericGenerator(name = "secondFKeyGenerator",
strategy = "foreign",
parameters = @Parameter(name = "property", value = "first")
)
private Long id;
@OneToOne(fetch = FetchType.LAZY, optional = false)
@PrimaryKeyJoinColumn
private First first;
...
}
[01/19 20:43:58] DEBUG [org.hibernate.tool.hbm2ddl.SchemaExport] - <create table TEST_FIRST (id bigint not null, primary key (id))>
[01/19 20:43:58] DEBUG [org.hibernate.tool.hbm2ddl.SchemaExport] - <create table TEST_SECOND (id bigint not null, primary key (id))>
[01/19 20:43:58] DEBUG [org.hibernate.tool.hbm2ddl.SchemaExport] - <alter table TEST_SECOND add constraint FKDE710C1188F241B foreign key (id) references TEST_FIRST>
...
...
persist================================================
[01/19 20:45:50] TRACE [org.hibernate.event.def.AbstractSaveEventListener] - <transient instance of: eg.test.First>
[01/19 20:45:50] TRACE [org.hibernate.event.def.DefaultPersistEventListener] - <saving transient instance>
[01/19 20:45:50] DEBUG [org.hibernate.jdbc.AbstractBatcher] - <opening JDBC connection>
[01/19 20:45:50] TRACE [org.hibernate.connection.DriverManagerConnectionProvider] - <total checked-out connections: 1>
[01/19 20:45:50] DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] - <opening new JDBC connection>
[01/19 20:45:50] DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] - <created connection to: jdbc:hsqldb:., Isolation Level: 2>
[01/19 20:45:50] DEBUG [org.hibernate.SQL] - <select next_val id_val from hibernate_sequence>
[01/19 20:45:50] DEBUG [org.hibernate.SQL] - <update hibernate_sequence set next_val= ? where next_val=?>
[01/19 20:45:50] DEBUG [org.hibernate.jdbc.AbstractBatcher] - <closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)>
[01/19 20:45:50] TRACE [org.hibernate.connection.DriverManagerConnectionProvider] - <returning connection to pool, pool size: 1>
[01/19 20:45:50] DEBUG [org.hibernate.event.def.AbstractSaveEventListener] - <generated identifier: 1, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator>
[01/19 20:45:50] TRACE [org.hibernate.event.def.AbstractSaveEventListener] - <saving [eg.test.First#1]>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <processing cascade ACTION_PERSIST_SKIPLAZY for: eg.test.First>
[01/19 20:45:50] TRACE [org.hibernate.engine.CascadingAction] - <cascading to persist: eg.test.Second>
[01/19 20:45:50] TRACE [org.hibernate.event.def.AbstractSaveEventListener] - <transient instance of: eg.test.Second>
[01/19 20:45:50] TRACE [org.hibernate.event.def.DefaultPersistEventListener] - <saving transient instance>
[01/19 20:45:50] DEBUG [org.hibernate.event.def.AbstractSaveEventListener] - <generated identifier: 1, using strategy: org.hibernate.id.ForeignGenerator>
[01/19 20:45:50] TRACE [org.hibernate.event.def.AbstractSaveEventListener] - <saving [eg.test.Second#1]>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <done processing cascade ACTION_PERSIST_SKIPLAZY for: eg.test.First>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <processing cascade ACTION_PERSIST_SKIPLAZY for: eg.test.First>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <done processing cascade ACTION_PERSIST_SKIPLAZY for: eg.test.First>
commit================================================
[01/19 20:45:50] DEBUG [org.hibernate.transaction.JDBCTransaction] - <commit>
[01/19 20:45:50] TRACE [org.hibernate.impl.SessionImpl] - <automatically flushing session>
[01/19 20:45:50] TRACE [org.hibernate.event.def.AbstractFlushingEventListener] - <flushing session>
[01/19 20:45:50] DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - <processing flush-time cascades>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <processing cascade ACTION_PERSIST_ON_FLUSH for: eg.test.Second>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <done processing cascade ACTION_PERSIST_ON_FLUSH for: eg.test.Second>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <processing cascade ACTION_PERSIST_ON_FLUSH for: eg.test.First>
[01/19 20:45:50] TRACE [org.hibernate.engine.CascadingAction] - <cascading to persistOnFlush: eg.test.Second>
[01/19 20:45:50] TRACE [org.hibernate.event.def.AbstractSaveEventListener] - <persistent instance of: eg.test.Second>
[01/19 20:45:50] TRACE [org.hibernate.event.def.DefaultPersistEventListener] - <ignoring persistent instance>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <processing cascade ACTION_PERSIST_ON_FLUSH for: eg.test.Second>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <done processing cascade ACTION_PERSIST_ON_FLUSH for: eg.test.Second>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <processing cascade ACTION_PERSIST_ON_FLUSH for: eg.test.Second>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <done processing cascade ACTION_PERSIST_ON_FLUSH for: eg.test.Second>
[01/19 20:45:50] TRACE [org.hibernate.engine.Cascade] - <done processing cascade ACTION_PERSIST_ON_FLUSH for: eg.test.First>
[01/19 20:45:50] DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - <dirty checking collections>
[01/19 20:45:50] TRACE [org.hibernate.event.def.AbstractFlushingEventListener] - <Flushing entities and processing referenced collections>
[01/19 20:45:50] TRACE [org.hibernate.event.def.AbstractFlushingEventListener] - <Processing unreferenced collections>
[01/19 20:45:50] TRACE [org.hibernate.event.def.AbstractFlushingEventListener] - <Scheduling collection removes/(re)creates/updates>
[01/19 20:45:50] DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - <Flushed: 2 insertions, 0 updates, 0 deletions to 2 objects>
[01/19 20:45:50] DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] - <Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections>
[01/19 20:45:50] DEBUG [org.hibernate.pretty.Printer] - <listing entities:>
[01/19 20:45:50] DEBUG [org.hibernate.pretty.Printer] - <eg.test.Second{first=eg.test.First#1, id=1}>
[01/19 20:45:50] DEBUG [org.hibernate.pretty.Printer] - <eg.test.First{second=eg.test.Second#1, id=1}>
[01/19 20:45:50] TRACE [org.hibernate.event.def.AbstractFlushingEventListener] - <executing flush>
[01/19 20:45:50] TRACE [org.hibernate.jdbc.ConnectionManager] - <registering flush begin>
[01/19 20:45:50] TRACE [org.hibernate.persister.entity.AbstractEntityPersister] - <Inserting entity: [eg.test.Second#1]>
[01/19 20:45:50] DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to open PreparedStatement (open PreparedStatements: 0, globally: 0)>
[01/19 20:45:50] DEBUG [org.hibernate.SQL] - <insert into TEST_SECOND (id) values (?)>
[01/19 20:45:50] TRACE [org.hibernate.jdbc.AbstractBatcher] - <preparing statement>
[01/19 20:45:50] TRACE [org.hibernate.persister.entity.AbstractEntityPersister] - <Dehydrating entity: [eg.test.Second#1]>
[01/19 20:45:50] TRACE [org.hibernate.type.LongType] - <binding '1' to parameter: 1>
[01/19 20:45:50] TRACE [org.hibernate.persister.entity.AbstractEntityPersister] - <Inserting entity: [eg.test.First#1]>
[01/19 20:45:50] DEBUG [org.hibernate.jdbc.AbstractBatcher] - <Executing batch size: 1>
[01/19 20:45:50] DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to close PreparedStatement (open PreparedStatements: 1, globally: 1)>
[01/19 20:45:50] TRACE [org.hibernate.jdbc.AbstractBatcher] - <closing statement>
[01/19 20:45:50] DEBUG [org.hibernate.util.JDBCExceptionReporter] - <Could not execute JDBC batch update [insert into TEST_SECOND (id) values (?)]>
java.sql.BatchUpdateException: failed batch