Re: Making the most of code



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
.



Relevant Pages

  • Re: Searching OO Associations with RDBMS Persistence Models
    ... The problem is that not all OO purists agree to this. ... come from a world where the database is a prominant feature. ... of services and Mixins (rows and ... transience and persistence in whether it is refering to the location ...
    (comp.object)
  • Re: SQL
    ... the features of a relational database are primarily that it allows ... >> or less) to the relational model, and and it does so in a persistent ... >> manner (what you put into the database isn't going to disappear unless you ... >> If we ignore the persistence aspect, what remains is the organization of ...
    (comp.object)
  • Re: OOP - a question about database access
    ... What I've decided to do is try to take a little database ... In a properly partitioned application the persistence access ... > if data is stored in an RDB, an OODB, flat files, or clay tablets. ... As a result one can abstract persistence mechanisms in terms ...
    (comp.object)
  • Re: An idea
    ... >> an idea for a more general persistence system. ... How do you map associations between objects? ... In the case of a relational database, how do you get your software to ... Originally I'd thought about mapping based on the instance field's name, ...
    (comp.lang.java.programmer)
  • Re: OOP - a question about database access
    ... >>(I'm going to use Java in a JDeveloper environment and the database is ... > Your concern should be the object model, which you don't even hit on. ... > possibly by using a common mechanism/library for persistence. ... I've seen systems that load entire object trees ...
    (comp.object)