-->
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.  [ 2 posts ] 
Author Message
 Post subject: JPA: setting a default entity for a not-null column.
PostPosted: Fri Feb 20, 2009 12:16 pm 
Newbie

Joined: Thu Jun 22, 2006 12:11 am
Posts: 14
Ok so I will give you some background so you can understand what I want to achieve.

I am working on a legacy system which has columns which are not-null and the default value is zero, these are foriegn key columns.

now, we can't add the "zero" columns on the tables because it will break be more than likely break legacy SQL statements, or atleast include false results.

alternately we can't make these columns nullable because we will also break certain legacy functions.

But I can't fully utilize JPA/Hibernate because without these "zero" columns (and there associated entities) when I create entities they are un-persistable (lookup is fine as long as i dont touch the zero columns), and not having these columns mapped defeats the point of using JPA/Hib as I may as well use straight SQL/JDBC

So what I want to know is, if there is a way to set these columns up as nullable in my entity, and when I try to persist them it will automatically fill them out with zero.

please ask questions so I can clarify, I am pretty stumped :\


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2009 2:33 pm 
Newbie

Joined: Thu Jun 22, 2006 12:11 am
Posts: 14
also because we are using an older version of mysql we can't take advantage of triggers and the like.

really it would be great if when I set the entity field to null, jpa/hib would insert "0" into the column.

though I think what I want is impossible


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

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.