users
[Top] [All Lists]

Re: [cinjug-users] Hibernate and database default values

To: Kedar Jog <kedar.jog@xxxxxxxxx>
Subject: Re: [cinjug-users] Hibernate and database default values
From: Bill Manuel <bill.manuel@xxxxxxxxx>
Date: Wed, 20 Jul 2005 18:21:50 -0400
Cc: users@xxxxxxxxxx
Delivered-to: mailing list users@cinjug.org
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; b=RFcpnhh6MI8gJH+ARAIQIykCCXjrNdy+Zw+7WJ/hVYo09we1c2lhwXboFoU4c0liPSmBoT0E4r0ieJ9xX9H+JKK9MeKYxlPMf1NCRKv5nVD4louAhlfR7HoE7HEIlbnW2RwO8CBLoTYA/TMZQ91691fl45P7BMxMVsV96rtK31I=
In-reply-to: <d176668005072014186cbb0b6e@mail.gmail.com>
Mailing-list: contact users-help@cinjug.org; run by ezmlm
References: <bd171aba05072014081a13ca1b@mail.gmail.com> <d176668005072014186cbb0b6e@mail.gmail.com>
Reply-to: Bill Manuel <bill.manuel@xxxxxxxxx>
I think I could have stated this a little better.  I am trying to figure out how to use the default value on the database.  The database schema is the only place that I am not allowing null values.  I understand that hibernate will insert whatever value that I tell it.  This is what I am trying to prevent.  When I do an insert on a newly created object, I don't want to insert one of the properties, I want the database to set the default value for me.  I know I could just remove the property from the hibernate config, but then I would not be able to read or update the field in the database.  I was hoping that If I set the property to null on the object, hibernate would read my mind and use the database default value.  :)

There certainly has to be a way to do this.

Thanks for the input.

On 7/20/05, Kedar Jog <kedar.jog@xxxxxxxxx> wrote:
Hibernate will try and insert whatever the  value of the property in
your object is if null it will try and persist a null value so on and
so forth

if the column is not null in the schema  why are u passing in a nul
value ? if u expect the value to be null , change your xdoclet tags to
reflect this situation regenerate your hbm files and regen and
redeploy the schema you can also use @hibernate.property formula="some
sql stmt" to add a default computed value....


Kedar Jog
Senior J2EE Engineer
MedPlus (www.medplus.com)


On 7/20/05, Bill Manuel < bill.manuel@xxxxxxxxx> wrote:
> Does anyone know how to make hibernate accept the default values of the
> database on an insert?  The column in the database is not nullable, so when
> I set the value of the property to null, the database crys becasue of the
> null value.
>
> Any help is appreciated.
>
> Thanks
> Bill Manuel
>


--
Regards

Kedar

-----------------------------------
Kedar Jog
5908 Monassas Run Rd
Milford OH 45150

---------
You may unsubscribe from this mailing list
by sending a blank email addressed to:
users-unsubscribe@xxxxxxxxxx

--
Find additional help by sending a blank email
addressed to:
users-help@xxxxxxxxxx


<Prev in Thread] Current Thread [Next in Thread>