-->
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.  [ 1 post ] 
Author Message
 Post subject: Using a custom type to validate string length?
PostPosted: Tue Aug 12, 2014 10:40 am 
Regular
Regular

Joined: Tue Sep 09, 2003 9:37 pm
Posts: 56
Location: Ogden, Utah, USA
Using: Hibernate 4.3.5, MS SQL Server

What is the best way to use the JPA @Column length information to validate the data length at the time of persistence?

I've read countless messages that suggest
1) validate in the UI
2) validate in your setter

My goal is not validation. My goal is giving the developer better feedback. Currently, if you are persisting an object with 100+ data elements and you get an error, it says 'data will be truncated' (Using Microsoft SQL Server). It does not specify which column is too long, and is generally unhelpful.

I would like to use the hibernate framework annotation information to produce a more useful exception.

Can this be done via custom user type? Is the length stored at all, or must it be retrieved via annotation reflection?

Thanks for any advice,
Jenica


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

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.