简体   繁体   中英

Hibernate Model Objects as VO objects

Most of the time I get this advice not to use hibernate model objects as my Value Objects or UI Objects. Will there be any issues if I use Hibernate model objects as VO objects or Form Objects in UI? If it is ok to use I can avoid copying values to and from the VO and model Objects.

I think you're right, there are no issues with that. It is a matter of context.

Hibernate model objects are simple POJOs with some metadata (annotations) attached to it. At the persistence layer this metadata means something, but in the view layer it means nothing.

This way in the view layer it acts as a VO, but in the persistence layer it acts as a model object, so it indeed eliminates the need for separate VOs.

This is the beauty of metadata.

If you're concerned with the security of an object travelling from UI to database, this would be another subject.

There are various ways to ensure security, but basically it would be achieved by using proper authentication and authorization mechanisms, queries with parameters and/or Criteria API.

For more info on that, please take a look at this and this .

I hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM