Hello all. I am trying to use the Session.save(Object o) / Session.saveOrUpdate(Object o) function. I am passing all the parameters correctly, and getting no exceptions. However, there is is no record in the DB pertaining to the insert. Has anyone else come across this?
I'm including my SQL, hbm.xml, and Java code, just in case I've missed something.
SQL:
Code:
CREATE TABLE dbo.SP_Events
(
EventId numeric(12,0) NOT NULL,
CloseDate date NOT NULL,
TrustNumber numeric(12,0) NOT NULL,
EventTypeId numeric(12,0) NULL,
StatusId numeric(12,0) NULL,
Notes varchar(256) NULL,
CONSTRAINT SP_Events_8285790091
PRIMARY KEY CLUSTERED (EventId,CloseDate,TrustNumber)
)
LOCK ALLPAGES
go
IF OBJECT_ID('dbo.SP_Events') IS NOT NULL
PRINT '<<< CREATED TABLE dbo.SP_Events >>>'
ELSE
PRINT '<<< FAILED CREATING TABLE dbo.SP_Events >>>'
go
Mapping (hbm.xml):Code:
<hibernate-mapping package="com.lehman.tims.persist">
<class name="SpEvents" table="SP_Events">
<composite-id name="id" class="SpEventsKey">
<key-property name="closedate" column="CloseDate" type="java.lang.String"/>
<key-property name="eventid" column="EventId" type="java.lang.Long"/>
<key-property name="trustnumber" column="TrustNumber" type="java.lang.Long"/>
</composite-id>
<property name="eventtypeid" column="EventTypeId" type="java.lang.Long" />
<property name="statusid" column="StatusId" type="java.lang.Long" />
<property name="notes" column="Notes" type="java.lang.String" />
</class>
</hibernate-mapping>
Java:Code:
public static void main( String args[] ) {
SpEventsKey eventsKey = new SpEventsKey();
eventsKey.setClosedate("01/01/2006");
eventsKey.setEventid( new Long("1") );
eventsKey.setTrustnumber( new Long("14") );
SpEvents events = new SpEvents();
events.setId( eventsKey );
events.setNotes( "Some notes" );
session.save( events );
session.flush();
session.close();
}