Re: Making the most of code
- From: Lew Bloch <conrad@xxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 28 May 2008 00:06:12 -0400
jstorta wrote:
....I have a web site that uses JSP and some back end classes to manage
data in a MySQL database. It does okay and has run well for about 3
years. It has, however, grown to the point where I need to redesign
some of it to be more dynamic. I've recently started incorporating
Hibernate and JavaServer Faces to ease the development now and make it
easier for me to make changes later on. Or at least that was my plan.
If anyone can point me toward some documentation that might help set
me straight, I would appreciate it.
<http://java.sun.com/javaee/5/docs/tutorial/doc/bnbpy.html>
Hibernate implements the Java Persistence API (JPA). Although the referenced link is a tutorial, I find it a bit opaque, especially trying to convert it to running code. I deem patience a virtue with this one.
O'Reilly has a Hibernate book out with a good reputation. I don't know if it's any clearer than the documentation at or through hibernate.org, though.
That same tutorial link leads to chapters on JSF, also. "Persistence", the part linked, is Part V. "The Web Tier" is Part II. The overall link is
<http://java.sun.com/javaee/5/docs/tutorial/doc/>
Abhijat Vatsyayan wrote:
You should think along [the lines of] separating your domain representation from details of persistence technology. Sure, every class that corresponds to a table needs to be saved but if you have a one-to-one correspondence between database tables and classes, your (mapped) classes are pure data with no behaviour (except the ability to persist).
JPA frameworks, and the other object-relational mapping (ORM) frameworks I've seen for Java, use pure value objects to represent entities. This may seem strange to O-O programmers accustomed to objects that manage their own behaviors, but it's valid. Persistence actions use entity objects, but their concerns are not those of an entity. An entity just is, in its own mind, and it takes its values as gifts. Any behaviors it does have will not relate to persistence, but to its own concerns, trusting persistence matters to the layer that handles them.
The closest a JPA-annotated class has to knowing its persistence responsibilities is a declarative set of hints and assertions that do not constrain the mechanism used to achieve their purpose. Sure, '@Entity' tells a class that it is an entity, perhaps revealing the associated database table and such things, but nothing at all about how that is accomplished.
--
Lew
.
- Follow-Ups:
- Re: Making the most of code
- From: RedGrittyBrick
- Re: Making the most of code
- References:
- Making the most of code
- From: jstorta
- Re: Making the most of code
- From: Abhijat Vatsyayan
- Making the most of code
- Prev by Date: Re: applets = javascripts?
- Next by Date: Re: Extracting a String value with ANT
- Previous by thread: Re: Making the most of code
- Next by thread: Re: Making the most of code
- Index(es):
Relevant Pages
|
|