-->
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: Problem inserting dependant object with trigger
PostPosted: Thu May 18, 2006 1:13 pm 
Newbie

Joined: Thu May 18, 2006 1:04 pm
Posts: 1
Basically, I have a trigger declared as instead insert on my database to check some constraints. If this trigger is enabled, is like hibernate cannot set the autogenerated (identity column on sql server) into the address object to persist it. If i disabled the trigger, all works well.

I'm using jTDS driver in case this makes a difference.

Hibernate version:2.1.18

Mapping documents:
person has a set of addresses. address maps back to person.
Code between sessionFactory.openSession() and session.close():
session.save(object);
session.flush();
Full stack trace of any exception that occurs:

Name and version of the database you are using:
SQL Server 2004
The generated SQL (show_sql=true):
Hibernate: insert into PERSON (_version, given_name, middle_name, surname, initi
als, US_citizen_ind, primary_email_address, person_oid, _oid_sequence, unpublish
ed_ind, _state, _locality, _created_timestamp, _created_by, _modified_timestamp,
_modified_by, _active_ind) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?)
Hibernate: insert into ADDRESS (_version, person_id, address_line_one, postal_co
de_1, country, state, locality, address_type, published_ind, _created_timestamp,
_created_by, _modified_timestamp, _modified_by, _active_ind) values (?, ?, ?, ?
, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Debug level Hibernate log excerpt:

2:26:09,364 WARN JDBCExceptionReporter:38 - SQL Error: 547, SQLState: 23000
2:26:09,364 ERROR JDBCExceptionReporter:46 - INSERT statement conflicted with C
LUMN FOREIGN KEY constraint 'FK_person2000'. The conflict occurred in database
PHINDIR_1.2.0', table 'person', column 'person_id'.
2:26:09,364 WARN JDBCExceptionReporter:38 - SQL Error: 547, SQLState: 23000
2:26:09,364 ERROR JDBCExceptionReporter:46 - INSERT statement conflicted with C
LUMN FOREIGN KEY constraint 'FK_person2000'. The conflict occurred in database
PHINDIR_1.2.0', table 'person', column 'person_id'.
2:26:09,364 ERROR JDBCExceptionReporter:38 - could not insert: [gov.phindir.pla
form.common.transferObjects.Address]
ava.sql.SQLException: INSERT statement conflicted with COLUMN FOREIGN KEY const
aint 'FK_person2000'. The conflict occurred in database 'PHINDIR_1.2.0', table
person', column 'person_id'.
----------
FK_person2000 is the FK constraint on address.person_id column mapping to the person.person_id


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.