Hi all,
I am simply running the application from Hibernate's Chapter 1 doc.
1. Why am I seeing 2 different insert commands on the client and server side (see below)?
2. Assuming I wish to insert more than one record, how can I configure Hibernate to avoid preparing 2 different INSERT statements and to actually do some parameter bindings?
Hibernate version: 3.1
Mapping documents:
<?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="hib1.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
session.beginTransaction();
Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);
session.save(theEvent);
session.getTransaction().commit();
Full stack trace of any exception that occurs:
Name and version of the database you are using:
Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
The generated SQL (show_sql=true):
from log:
Hibernate: insert into EVENTS (EVENT_DATE, title) values (?, ?) select scope_identity()
from SQL Profiler (server-side):
exec sp_executesql N'insert into EVENTS (EVENT_DATE, title) values (@P1, @P2) select scope_identity()', N'@P1 datetime ,@P2 nvarchar(4000) ', 'Jun 12 2006 2:27:59:900PM', N'My Event'
Debug level Hibernate log excerpt:
|