-->
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: Unable to persist new object w/ attached existing object.
PostPosted: Fri Sep 12, 2014 4:15 pm 
Newbie

Joined: Fri Sep 12, 2014 3:59 pm
Posts: 1
Hi,
I'm a new user being stymied by what I think should be a really straightforward operation. I am trying to load a user from the database, attach it to a new object, and then persist that new object. I am seeing the error

Code:
Unable to complete task: org.hibernate.exception.ConstraintViolationException: Cannot insert the value NULL into column 'ACTOR', table 'MY_DATABASE.dbo.AUDIT_LOG_ENTRY'; column does not allow nulls. INSERT fails.


My understanding was that the load() method throws an exception if the User object can't be found in the database. Just to be sure, I checked, and it is definitely not null. I know it might be a proxy, but I'm in the same session, so that shouldn't be an issue, right? What am I doing wrong here?

Code:
final Integer userId = ...;
final User user =
        (User) session.load(User.class, userId);

final AuditLogEntry auditLogEntry = new AuditLogEntry();
// other properties are set here
auditLogEntry.setActor(user);
session.save(auditLogEntry);


Thanks,
Eric


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.