Question

Wondering if it is a good or bad ideal to make use of Hibernate UserType to trim data from an incoming data feed to prevent exceptions thrown if the data is to large to fit into the given column.

We receive data from a lot of data sources and have no control on the size of the data that is sent.

We are looking at about 100 fields in which we would need to create this for.

Was it helpful?

Solution

You don't need a custom UserType for this. Just put the logic on the Pojos that are being submitted, in the setters. Or create a validate() method that validates the state of the object and call that method before persisting.

OTHER TIPS

A custom UserType seems like a more DRY solution than the setters approach. A validate method seems ugly too.

I'm looking for a better alternative to a custom UserType also but so far have not found one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top