-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate-powered Application design
PostPosted: Sun Jun 06, 2004 4:10 pm 
Beginner
Beginner

Joined: Thu Oct 09, 2003 11:41 am
Posts: 39
Location: Paris, France
Hello,

Advice is sought as to the best practices of application design with Hibernate. I have classes that represent persistent objects. Classes (java files) are generated from the mappings, and the database structure is also generated from the mappings.

I need toi implement certain functionality pertaining to each class/object. For example, a persisted parent contains a list of children. The Application should be able to find easily a certain child and perform some operations on it (such as remove, update, sort, etc etc.). The logical way of doing this is implement a method in the Parent class that will do all the work. However, it would involve the manual modification of the mapping class, and therefore the auto-generation of java files from mappings will involve copy-paste work each time (I'll have to move the methods to the newly generated java files). Besides, this approach is a bit against the whole Entity paradigm. The classes are supposed to be minimal, as they represent the object themselves, and do not contain business logic.

Is there a better way of solving this problem?

Thanks for your suggestions.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 06, 2004 5:04 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you should always add business logic into your POJO when it is possible.
Restricting a POJO into a simple entity persistent objet is a kind of antipattern we all know thanks to EJB 1.
Now how to use this when generating classes, mappings files... this is another question.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 12:44 am 
Beginner
Beginner

Joined: Thu May 13, 2004 5:51 am
Posts: 28
I have a similar problem.. I rely on my mapping files, to update database schema as well as generate the beans for me. To add additional logic into the beans I simply extend them from a base class that implements the logic.

--


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

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.