문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top