Hello,
I am new to hibernate and am running into issues deleting objects in a many-to-many bi-directional relationship while the inverse="true" flag is set.
I have two objects: Event and Person
My application is largely derived from hibernate.org chapter 1 tutorial.
http://www.hibernate.org/hib_docs/reference/en/html/tutorial.html
The application can:
* add/delete Events
* add/delete Persons
* add person to event
* remove person from event
Persons can register for many events.
Events can have many participants.
When a person is deleted, I want that person to automatically be deregistered from all registered events.
When an event is deleted, I want that event to be removed from all registered persons.
I am not sure if this is a parent-child relationship...it seems more like a peer-to-peer relationship (if such a thing exists?...maybe this is bad practice?)
The problem I run into is that when I try to delete the object that has the inverse="true" flag in its mapping file, hibernate throws an exception upon flushing/committing.
When I remove the inverse="true" flag from both mapping files, everything works fine, but I worry that this might be inefficient, or that I am missing some simple concept.
So here are my questions:
1) Why did hibernate throw an exception when deleting the object that has the inverse="true" in its mapping file?
2) Does a "peer-to-peer" relationship even exist? Or is it bad practice?
3) Is there a better way to delete objects in a (peer-to-peer?) bidirectional many-to-many relationship who have the inverse="true" flag in its mapping file?
web.xml and hibernate.cfg.xml files are identical to the hibernate tutorial. I'll happily provide them if needed.
Thanks
David
Hibernate version:
3.2
Mapping documents:
Event.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="events.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
<set name="participants" inverse="true" table="PERSON_EVENT">
<key column="EVENT_ID"/>
<many-to-many column="PERSON_ID" class="events.Person"/>
</set>
</class>
</hibernate-mapping>
Person.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="events.Person" table="PERSON">
<id name="id" column="PERSON_ID">
<generator class="native"/>
</id>
<property name="age"/>
<property name="firstname"/>
<property name="lastname"/>
<set name="events" table="PERSON_EVENT">
<key column="PERSON_ID"/>
<many-to-many column="EVENT_ID" class="events.Event"/>
</set>
<set name="emailAddresses" table="PERSON_EMAIL_ADDR">
<key column="PERSON_ID"/>
<element type="string" column="EMAIL_ADDR"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Here's the full servlet code:
EventManagerServlet.java
Code:
package events;
// Imports
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Date;
import util.HibernateUtil;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class EventManagerServlet extends HttpServlet {
protected void doGet( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException {
SimpleDateFormat dateFormatter = new SimpleDateFormat( "dd.MM.yyyy" );
try {
// Begin unit of work
HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
// Process request and render page...
// Write HTML header
PrintWriter out = response.getWriter();
out.println( "<html><head><title>Event Manager</title></head><body>" );
//Handle actions
String action = request.getParameter( "action" );
if ( action != null ) {
if ( action.equals( "addPerson" ) ) {
String firstname = request.getParameter( "firstname" );
String lastname = request.getParameter( "lastname" );
String age = request.getParameter( "age" );
createAndStorePerson( firstname, lastname, new Integer( age ).intValue() );
out.println( "<b><i>Added person.</i></b>" );
} else if ( action.equals( "removePerson" ) ) {
String id = request.getParameter( "personId" );
removePerson( new Long( id ) );
out.println( "<b><i>Removed Person.</i></b>" );
} else if ( action.equals( "addEvent" ) ) {
String eventTitle = request.getParameter( "eventTitle" );
String eventDate = request.getParameter( "eventDate" );
try {
createAndStoreEvent( eventTitle, dateFormatter.parse( eventDate ) );
out.println( "<b><i>Added event.</i></b>" );
} catch ( ParseException ex ) {
out.println( "<b><i>Parse Exception!</i></b>" );
}
} else if ( action.equals( "removeEvent" ) ) {
String id = request.getParameter( "eventId" );
try {
removeEvent( new Long( id ) );
} catch ( Exception ex ) {
out.println( "Error during remove event!: " + ex );
return;
}
out.println( "<b><i>Removed Event.</i></b>" );
} else if ( action.equals( "addPersonToEvent" ) ) {
String personId = request.getParameter( "personId" );
String eventId = request.getParameter( "eventId" );
try {
addPersonToEvent( new Long( personId ), new Long( eventId ) );
} catch ( Exception ex ) {
out.println( "error adding person to event: " + ex );
ex.printStackTrace();
}
out.println( "Added person to event" );
} else if ( action.equals( "removePersonFromEvent" ) ) {
String personId = request.getParameter( "personId" );
String eventId = request.getParameter( "eventId" );
removePersonFromEvent( new Long( personId ), new Long( eventId ) );
out.println( "Removed person from event" );
}
try {
HibernateUtil.getSessionFactory().getCurrentSession().flush();
} catch ( Exception ex ) {
out.println( "Error during flush!: " + ex );
ex.printStackTrace();
return;
}
}
out.println( "<br/>" );
try {
//Print list
listPeople( out );
try {
//Print events
listEvents( out, dateFormatter );
} catch ( Exception ex ) {
out.println( "Error during printing events! " + ex );
ex.printStackTrace();
return;
}
//Print the action form
printForm( out );
} catch ( Exception ex ) {
out.println( "Error during printing! " + ex );
ex.printStackTrace();
return;
}
try {
// End unit of work
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
} catch ( Exception ex ) {
out.println( "Error during commit!: " + ex );
ex.printStackTrace();
}
// Write HTML footer
out.println( "</body></html>" );
out.flush();
out.close();
} catch ( Exception ex ) {
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().rollback();
throw new ServletException( ex.getMessage() );
}
}
private void printForm( PrintWriter out ) {
out.println( "<table border='1'><tr><td>" );
out.println( "<h2>Add new event:</h2>" );
out.println( "<form>" );
out.println( "Title: <input name='eventTitle' length='50'/><br/>" );
out.println( "Date (e.g. 24.12.2009): <input name='eventDate' length='10'/><br/>" );
out.println( "<input type='submit' name='action' value='addEvent' />" );
out.println( "</form>" );
out.println( "</td><td>" );
out.println( "<h2>Remove event:</h2>" );
out.println( "<form>" );
out.println( "ID: <input name='eventId' length='50'/><br/>" );
out.println( "<input type='submit' name='action' value='removeEvent' />" );
out.println( "</form>" );
out.println( "</td></tr></table>" );
out.println( "<br/>" );
out.println( "<table border='1'><tr><td>" );
out.println( "<h2>Add new person:</h2>" );
out.println( "<form>" );
out.println( "First Name: <input name='firstname' length='50'/><br/>" );
out.println( "Last Name: <input name='lastname' length='50' /><br/>" );
out.println( "Age: <input name='age' length='4' /><br/>" );
out.println( "<input type='submit' name='action' value='addPerson' />" );
out.println( "</form>" );
out.println( "</td><td>" );
out.println( "<h2>Remove Person:</h2>" );
out.println( "<form>" );
out.println( "ID: <input name='personId' length='50'/><br/>" );
out.println( "<input type='submit' name='action' value='removePerson' />" );
out.println( "</form>" );
out.println( "</td></tr></table>" );
out.println( "<br/>" );
out.println( "<table border='1'><tr><td>" );
out.println( "<h2>Register person for event:</h2>" );
out.println( "<form>" );
out.println( "Person ID: <input name='personId' length='50'/><br/>" );
out.println( "Event ID: <input name='eventId' length='50'/><br/>" );
out.println( "<input type='submit' name='action' value='addPersonToEvent' />" );
out.println( "</form>" );
out.println( "</td><td>" );
out.println( "<h2>Remove person from event:</h2>" );
out.println( "<form>" );
out.println( "Person ID: <input name='personId' length='50'/><br/>" );
out.println( "Event ID: <input name='eventId' length='50'/><br/>" );
out.println( "<input type='submit' name='action' value='removePersonFromEvent' />" );
out.println( "</form>" );
out.println( "</td></tr></table>" );
}
private void listPeople( PrintWriter out ) {
List result = HibernateUtil.getSessionFactory().getCurrentSession().createCriteria(
Person.class ).list();
if ( result.size() > 0 ) {
out.println( "<h2>People in database:</h2>" );
out.println( "<table border='1'>" );
out.println( "<tr>" );
out.println( "<th>ID</th>" );
out.println( "<th>Name</th>" );
out.println( "<th>Age</th>" );
out.println( "<th>Registered Events</th>" );
out.println( "</tr>" );
for ( Iterator it = result.iterator(); it.hasNext(); ) {
Person person = (Person)it.next();
out.println( "<tr>" );
out.println( "<td>" + person.getId() + "</td>" );
out
.println( "<td>" + person.getLastname() + ", " + person.getFirstname()
+ "</td>" );
out.println( "<td>" + person.getAge() + "</td>" );
Set events = person.getEvents();
if ( events == null || events.size() < 1 ) {
out.println( "<td>Not registered for any events.</td>" );
} else {
out.println( "<td>Registered for " + events.size() + " events.</td>" );
}
out.println( "</tr>" );
}
out.println( "</table>" );
} else {
out.println( "<h2>No people found.</h2>" );
}
}
private void listEvents( PrintWriter out, SimpleDateFormat dateFormatter ) {
List result = HibernateUtil.getSessionFactory().getCurrentSession().createCriteria(
Event.class ).list();
if ( result.size() > 0 ) {
out.println( "<h2>Events in database:</h2>" );
out.println( "<table border='1'>" );
out.println( "<tr>" );
out.println( "<th>Id</th>" );
out.println( "<th>Event title</th>" );
out.println( "<th>Event date</th>" );
out.println( "<th>Participants</th>" );
out.println( "</tr>" );
for ( Iterator it = result.iterator(); it.hasNext(); ) {
Event event = (Event)it.next();
out.println( "<tr>" );
out.println( "<td>" + event.getId() + "</td>" );
out.println( "<td>" + event.getTitle() + "</td>" );
out.println( "<td>" + dateFormatter.format( event.getDate() ) + "</td>" );
Set participants = event.getParticipants();
if ( participants == null || participants.size() < 1 ) {
out.println( "<td>No participants.</td>" );
} else {
out.println( "<td>" + participants.size() + " participants found.</td>" );
}
out.println( "</tr>" );
}
out.println( "</table>" );
} else {
out.println( "<h2>No events found.</h2>" );
}
}
protected void createAndStorePerson( String firstname, String lastname, int age ) {
Person thePerson = new Person();
thePerson.setFirstname( firstname );
thePerson.setLastname( lastname );
thePerson.setAge( age );
HibernateUtil.getSessionFactory().getCurrentSession().save( thePerson );
}
protected void createAndStoreEvent( String title, Date theDate ) {
Event theEvent = new Event();
theEvent.setTitle( title );
theEvent.setDate( theDate );
HibernateUtil.getSessionFactory().getCurrentSession().save( theEvent );
}
protected void removePerson( Long id ) {
Person person = (Person)HibernateUtil.getSessionFactory().getCurrentSession().load(
Person.class, id );
HibernateUtil.getSessionFactory().getCurrentSession().delete( person );
}
protected void removeEvent( Long id ) {
Event event = (Event)HibernateUtil.getSessionFactory().getCurrentSession().load(
Event.class, id );
HibernateUtil.getSessionFactory().getCurrentSession().delete( event );
}
private void addPersonToEvent( Long personId, Long eventId ) {
Person aPerson = (Person)HibernateUtil.getSessionFactory().getCurrentSession().load(
Person.class, personId );
Event anEvent = (Event)HibernateUtil.getSessionFactory().getCurrentSession().load(
Event.class, eventId );
aPerson.getEvents().add( anEvent );
//anEvent.getParticipants().add(aPerson);
}
private void removePersonFromEvent( Long personId, Long eventId ) {
Person aPerson = (Person)HibernateUtil.getSessionFactory().getCurrentSession().load(
Person.class, personId );
Event anEvent = (Event)HibernateUtil.getSessionFactory().getCurrentSession().load(
Event.class, eventId );
aPerson.getEvents().remove( anEvent );
//anEvent.getParticipants().remove(aPerson);
}
}
Full stack trace of any exception that occurs:Code:
Hibernate: delete from EVENTS where EVENT_ID=?
10:51:08,885 WARN JDBCExceptionReporter:77 - SQL Error: 0, SQLState: null
10:51:08,885 ERROR JDBCExceptionReporter:78 - failed batch
10:51:08,901 ERROR AbstractFlushingEventListener:301 - Could not synchronize dat
abase state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch updat
e
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException
(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.j
ava:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:146)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutio
ns(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlus
hEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtection
Wrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy4.flush(Unknown Source)
at events.EventManagerServlet.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
rValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
534)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:15
2)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.BatchUpdateException: failed batch
at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.jav
a:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
246)
... 45 more
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch updat
e
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException
(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.j
ava:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:146)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutio
ns(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlus
hEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtection
Wrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy4.flush(Unknown Source)
at events.EventManagerServlet.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
rValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
534)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:15
2)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.BatchUpdateException: failed batch
at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.jav
a:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
246)
... 45 more
Name and version of the database you are using:HSQLDB 1.8.0
The generated SQL (show_sql=true):SQL from:
Viewing current persons and events
Adding one personViewing current persons and events
Adding one eventViewing current persons and events
Registering person for eventViewing current persons and events
Deleting event Code:
Hibernate: select this_.PERSON_ID as PERSON1_2_0_, this_.age as age2_0_, this_.f
irstname as firstname2_0_, this_.lastname as lastname2_0_ from PERSON this_
Hibernate: select this_.EVENT_ID as EVENT1_0_0_, this_.EVENT_DATE as EVENT2_0_0_
, this_.title as title0_0_ from EVENTS this_
Hibernate: insert into EVENTS (EVENT_ID, EVENT_DATE, title) values (null, ?, ?)
Hibernate: call identity()
Hibernate: select this_.PERSON_ID as PERSON1_2_0_, this_.age as age2_0_, this_.f
irstname as firstname2_0_, this_.lastname as lastname2_0_ from PERSON this_
Hibernate: select this_.EVENT_ID as EVENT1_0_0_, this_.EVENT_DATE as EVENT2_0_0_
, this_.title as title0_0_ from EVENTS this_
Hibernate: insert into PERSON (PERSON_ID, age, firstname, lastname) values (null
, ?, ?, ?)
Hibernate: call identity()
Hibernate: select this_.PERSON_ID as PERSON1_2_0_, this_.age as age2_0_, this_.f
irstname as firstname2_0_, this_.lastname as lastname2_0_ from PERSON this_
Hibernate: select this_.EVENT_ID as EVENT1_0_0_, this_.EVENT_DATE as EVENT2_0_0_
, this_.title as title0_0_ from EVENTS this_
Hibernate: select participan0_.EVENT_ID as EVENT1_1_, participan0_.PERSON_ID as
PERSON2_1_, person1_.PERSON_ID as PERSON1_2_0_, person1_.age as age2_0_, person1
_.firstname as firstname2_0_, person1_.lastname as lastname2_0_ from PERSON_EVEN
T participan0_ left outer join PERSON person1_ on participan0_.PERSON_ID=person1
_.PERSON_ID where participan0_.EVENT_ID=?
Hibernate: select person0_.PERSON_ID as PERSON1_2_0_, person0_.age as age2_0_, p
erson0_.firstname as firstname2_0_, person0_.lastname as lastname2_0_ from PERSO
N person0_ where person0_.PERSON_ID=?
Hibernate: select events0_.PERSON_ID as PERSON2_1_, events0_.EVENT_ID as EVENT1_
1_, event1_.EVENT_ID as EVENT1_0_0_, event1_.EVENT_DATE as EVENT2_0_0_, event1_.
title as title0_0_ from PERSON_EVENT events0_ left outer join EVENTS event1_ on
events0_.EVENT_ID=event1_.EVENT_ID where events0_.PERSON_ID=?
Hibernate: insert into PERSON_EVENT (PERSON_ID, EVENT_ID) values (?, ?)
Hibernate: select this_.PERSON_ID as PERSON1_2_0_, this_.age as age2_0_, this_.f
irstname as firstname2_0_, this_.lastname as lastname2_0_ from PERSON this_
Hibernate: select this_.EVENT_ID as EVENT1_0_0_, this_.EVENT_DATE as EVENT2_0_0_
, this_.title as title0_0_ from EVENTS this_
Hibernate: select participan0_.EVENT_ID as EVENT1_1_, participan0_.PERSON_ID as
PERSON2_1_, person1_.PERSON_ID as PERSON1_2_0_, person1_.age as age2_0_, person1
_.firstname as firstname2_0_, person1_.lastname as lastname2_0_ from PERSON_EVEN
T participan0_ left outer join PERSON person1_ on participan0_.PERSON_ID=person1
_.PERSON_ID where participan0_.EVENT_ID=?
Hibernate: select event0_.EVENT_ID as EVENT1_0_0_, event0_.EVENT_DATE as EVENT2_
0_0_, event0_.title as title0_0_ from EVENTS event0_ where event0_.EVENT_ID=?
Hibernate: delete from EVENTS where EVENT_ID=?