I've an entity class that is endured to some database via JPA and I've got a Utility class which does the persisting and reading through for me personally.
Now I am asking myself if that's really what you want. Would not it be clearer, when the data class might have techniques for reading through and conntacting the database?
Would not it be clearer, when the data class might have techniques for reading through and conntacting the database?
Yes. You have to take a look at DAO pattern
The conventional practice should consist following layers:
Model - Holds your POJO , simply planned classes
DAO - Interface driven classes which supplies CRUD of these POJO's
Service - Use DAO to have interaction with DB and perform business stuff here
Have a look here : http://en.wikipedia.org/wiki/Data_access_object It'll obvious things for you personally.
No, it's not great way. When you purchase this way, you'd couple your domain object logic with data access layer .. They're various things, so that you should decouple them.