-->
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.  [ 3 posts ] 
Author Message
 Post subject: Altering column sizes in a Database
PostPosted: Mon Jul 07, 2008 9:26 am 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
Hibernate version: 3.1

Name and version of the database you are using: Oracle 10g

Hi,

I need to know exactly how hibernate behaves in the following situation:

Note that all interactions with the database are read-only.

I have a column of size 30 correctly mapped in Hibernate. If the size is altered in the base but not in the mapping, will it result in an error when attempting to run Hibernate?

If no error occurs, what happens if the new size is smaller? And if it's bigger?
I'm guessing that if the new size is 32, if I try to query a value that's too large from it, Hibernate will truncate it.

Would it be wiser to omit the size from the mapping and let Hibernate deal with it?

I need to know what happens for both NUMBER/Big Decimal values and VARCHAR2/String values.

Thanks in advance.

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 07, 2008 3:08 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I think Hibernate in general ignores any size attributes in the mappings. It is only used by the schema-generation tool that can be used to generate the SQL that creates the database for you.

I guess the behavior depends on how Oracle is handling such things. I am mostly using MySQL and PostgreSQL and I think MySQL silently crop strings when inserting data while PostgreSQL fails (or maybe it was the other way around...).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 7:35 am 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
Thank you for the answer.

_________________
Falci - Heavy Worker!


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