In case it wasn't clear from Dinkar Rao's message, dynamically choosing which columns to read for an entity is *not* a standard feature of JPA, and to my knowledge is not being considered for inclusion in this round of the specification update that is not yet released.

If you want to do this in a standard, way, you would have to statically define different entities that map to the same tables and deal with side effects. Or use SQL queries.

Craig

On Oct 20, 2008, at 10:58 AM, baileyby wrote:


Is there a way to partially populate a POJO in dynamic fashion (i.e. without
using transient modifiers or annotations)?  For example, I may want to
populate my POJO's name and id in one situation, and yet populate name, id,
and createDate in another.  Such as, entityManager.createQuery("SELECT
MO.id, MO.name FROM MyObject MO") Surely, a purist would say that I should
always have a fully populated bean to ensure data integrity,
but it's simply
not reasonable for me to read in all of the possible columns in all
situations (see next paragraph). I've experimented and read through JSR220
spec, and didn't see anything like this.  Is it possible?

I have a table with about 500 columns, of which I am reading hundreds of rows very frequently. So, I can't reasonably fetch all 500 columns all of the time without sacrificing performance. In actuality, I only ever need about 20 columns, but which columns I need will change dynamically to suit
different needs.

Any ideas/suggestions are appreciated!
--
View this message in context: 
http://n2.nabble.com/Partial-populate-of-POJO-tp1356484p1356484.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:[EMAIL PROTECTED]
P.S. A good JDO? O, Gasp!

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to