• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic Entities

 
Joe Croft
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Srinivas,

I'm fairly new to to java (only a year or so) and come from a strong C/C++ with SQL background. Beyond absolute variable type checking, what is the benefit of having getters and setters for ever column in a table instead of using the dynamic entities?

In almost all of my experience, the programs use very little of the data and for the most part is just shoveling it from here to there or there to here. If I have a getter and setter for every column, everytime I make a change to the table, I need to change my code.

Is there a mechanism to decouple the code from the data structure besides dynamic entities?

Also, does JPA support dynamic entities?

Thanks,
Joe
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dynamic entities are a .NET concept (if I've understood what you mean), there is no real equivelent in JPA.


In almost all of my experience, the programs use very little of the data and for the most part is just shoveling it from here to there or there to here. If I have a getter and setter for every column, everytime I make a change to the table, I need to change my code.

How frequently does the data model change? In my experience, not frequently. If it does, there are plenty of code generation tools out there.
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPA does not have support for dynamic entities, but some JPA products, such as EclipseLink do.

See,
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Dynamic
 
Joe Croft
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:Dynamic entities are a .NET concept (if I've understood what you mean), there is no real equivelent in JPA.

...

How frequently does the data model change? In my experience, not frequently. If it does, there are plenty of code generation tools out there.


That's interesting about that being a .NET concept. Nobody will ever accuse me of being a proponent of MS, but sometimes they do seem to get something right.

I find that from customer to customer there is always the prospect of tweeking the schema. Also, during the time that a product matures, the schema will most certainly change. My point is, is why should the code be tied so tightly with the schema when there is no need for the code to manipulate the data, only move it from here to there, such as from a form to a record in the database, or a table on the screen to the database. If you provide a mapping of the data outside of the code to define the movement, the data can change and the code does not have to be touched and recompiled.

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I agree, things will change. But I suppose I can't see that this will really have much of an impact on your code (how hard is it to tweek and recompile your DAO layer?) and I'm not sure I would welcome the inevitable introduction of runtime bugs by replacing statically typed stuff with its dynamic equivalent. But then, this may just be two ways of looking at the same problem, so perhaps its just down to personal preference.

Either way, JPA does not support it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic