-->
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.  [ 6 posts ] 
Author Message
 Post subject: Default values on data base
PostPosted: Mon Aug 24, 2009 5:10 am 
Newbie

Joined: Tue Aug 18, 2009 9:24 am
Posts: 4
Hi everyone !

I've got a problem :

I've PostGreSQL data base , in my table , i've default values for attributes, ( for example , attributes Date , default value = now() )
I would like to used default values for insert on my data base.
Somebody know how i can do this ?

Thx a lot !!


Top
 Profile  
 
 Post subject: Re: Default values on data base
PostPosted: Mon Aug 24, 2009 7:56 am 
Newbie

Joined: Sun Aug 23, 2009 7:53 am
Posts: 8
Location: India
Hope this gonna help u:

<property name="property">
<column name="PROPERTY_VALUE" default="..." />
</property>



Even you can do it better and dynamic way creating a default (no-arg) constructor
with initializing the corresponding attributes with desired default values.

Bless me if it works......

_________________
Niraj


Top
 Profile  
 
 Post subject: Re: Default values on data base
PostPosted: Mon Aug 24, 2009 8:21 am 
Newbie

Joined: Tue Aug 18, 2009 9:24 am
Posts: 4
i've allways the same error :

" Caused by: java.sql.BatchUpdateException: L'élément du batch 0 insert into public.my_table (...) values (...) a été annulé"


Top
 Profile  
 
 Post subject: Re: Default values on data base
PostPosted: Mon Aug 24, 2009 8:34 am 
Newbie

Joined: Sun Aug 23, 2009 7:53 am
Posts: 8
Location: India
Your code must be trying to update the value of generator attribute, i mean primary key, that u r not suppose to do...

_________________
Niraj


Top
 Profile  
 
 Post subject: Re: Default values on data base
PostPosted: Mon Aug 24, 2009 8:53 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
You know, it's even more efficient if you can just set up default values at the db level, so if a null is sent, the db just puts in the default.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: Default values on data base
PostPosted: Mon Aug 24, 2009 9:04 am 
Newbie

Joined: Tue Aug 18, 2009 9:24 am
Posts: 4
ha ok ! thx!

my error must come from my request insert so ...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.