• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating new entities on the fly

 
Josean Delgado
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

I faced the following situation with JPA on a recent project:
I need to create new entities on the fly based on already existent entities.

As expected the new entities are not registered on initialization, there are no classes or tables on the db that represent them.
The new entities should be fully operational i.e navigation-able, search-able, etc. on the same User session that create them.

I wonder how can I handle this use case with JPA?

Thank you in advance
jD
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing in the JPA spec to do this.

What JPA provider are you using? Most have an internal way to register mappings for a class.

Where are the new classes coming from? They must be defined somewhere, so can't their persistence be defined as well?
 
Josean Delgado
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello James,

I am using Hibernate...
Some context: I am creating java-based web app using RAD new paradigms. I created an app named Grids-and-Charts (gnc).
GNC using a bunch of global indexes like: GNP, Education expenditure, Inflation, etc to create grids and charts with the data.
You can visit the app at gnc. The index data as originally defined is as a country/year pair.
The data have different years ranges. Creating the index grid and chart per country was straightforward. Next I wanted to provide some analytical
capabilities to gnc that requires operate the indexes of the countries all together. In other to do that I had to pivot the data to a have a country/y1/y2/y3/... view.

The sql for creating the pivot view was straightforward too. At that point JPA just would -only- need to know/register about the new entities -on the fly- to start operating on them.
That brought me to the search on JPA entities on the fly thing. I accomplished my goal using mostly oop. I wanted to know if there is a more automatic way for doing it.

Thank you
jD
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic