-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: What happens during insert to SQL Server?
PostPosted: Mon Jun 12, 2006 7:35 am 
Senior
Senior

Joined: Sun Jun 11, 2006 10:41 am
Posts: 164
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:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.