-->
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.  [ 5 posts ] 
Author Message
 Post subject: DataIntegrityViolationException - data too long for column
PostPosted: Thu Jun 22, 2006 6:46 pm 
Newbie

Joined: Thu Jun 22, 2006 6:33 pm
Posts: 3
Hi,

When i try to search for a data in oracle db whose length is greater than the column width, i get the below execption.

org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not execute query
DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: 1; nested exception is com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001

It works fine if i pass data <= column width.

Hibernate3.0
Spring1.2.7
DB2

Any of you faced this problem? please let me know how you fixed it?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 22, 2006 6:49 pm 
Senior
Senior

Joined: Sun Jun 04, 2006 1:58 am
Posts: 136
looks like this doesnt have to do anything with hibernate .
wondering What make you think that !!

_________________
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: DataIntegrityViolationException - data too long for colu
PostPosted: Thu Jun 22, 2006 6:52 pm 
Regular
Regular

Joined: Wed Feb 22, 2006 11:28 am
Posts: 65
Location: Santiago, Chile
Hello Friend:

All you have to do is check the word´s length before you do transaction.

If your are working with application based on web, you can constraints it simply when yo define your html tag line <input type="text" size="9" maxsize="10">.

If you want constraints it well, you can add the attribute "length" in the column tag in your hibernate mapping files, like follow:

<property name="word" type="string">
<column name="word_columnname" lenght="10">
</property>

I think if you write carefully , it will work fine.

Regards. Neketsu Shonen


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 22, 2006 6:59 pm 
Senior
Senior

Joined: Sun Jun 04, 2006 1:58 am
Posts: 136
No the length attribute doesnt do any validation checks !! . helps you in ddl generation .

Implementing this interface might help you

Quote:
http://www.hibernate.org/hib_docs/reference/en/html/persistent-classes.html#persistent-classes-

_________________
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 22, 2006 9:07 pm 
Newbie

Joined: Thu Jun 22, 2006 6:33 pm
Posts: 3
I know that restricting the user from entering more than the desired length or checking before executing the query would solve the issue. But i am just wondering why hibernate should validate on the column width when i am just quering the database. Ideally this should happen only when its inserted or updated.


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