Hi Daryl,
Thanks for your thoughts, your idea is interesting food for thought indeed. I'm a bit of a puritan when it come to abstractions, and while abstraction is a great thing I must confess to feeling that sometime I take it to the n'th degree and try push it too far. Lately I have been developing my first JPA application and after much research and soul-searching I went with OpenJPA rather than using Hibernate experience (non-JPA version) despite the fact that it's blowing out my timeframes, because I always find Apache software to be innovative and high quality. All of my entities are created (integrated using a fileinputstream of CSV or XLS/XLSX) using a model whereby I read the file headers then search for a setter method that uses "set"<column header name>, then call the setter. My next step is to load data columns that won't have setter methods on the entity class because at build time I may not know the additional custom field names. I guess my challenge is that since I know the entity won't have setters for the new column names in the data set, I want to be able to modify the entity calss at runtime to add the required setter method, then let the enhancer process the newly modified entity definition, then call the new setter method to let OpenJPA handle things as if I had defined these new entity members at design time. I could do this using JPA queries but it seems a little adhoc or impure, so I'm trying to think of a way of doing this without busting my puritanical vision. Chris From: Daryl Stultz [mailto:[email protected]] Sent: Friday, 24 July 2009 1:18 AM To: [email protected]; [email protected] Subject: Re: Dynamic entity definition creation - is it possible? On Thu, Jul 23, 2009 at 11:02 AM, C N Davies <[email protected]> wrote: I might be thinking in the wrong direction so feel free to berate me if I am. I'd like to berate you for building a self-modifying system, but I've done it myself, so I won't. I do have a project (not the self-modifying one) that has a need for adding "custom properties" to an entity. The entity has its core properties in the main table, then a list of custom properties in another table. Custom properties have a "definition" that describes datatype, presentation order and whatnot. In my pre-JPA system, presenting such an entity would involve a "pivot" on the custom properties. This is also required for JPA but you get it for "free" in that the custom property values come into the collection and it's easy enough to work with it in the rendering layer. I'm looking for ways to improve my solution, so don't think I'm proposing it as an alternative to yours. I am interested in how my solution would not work for you. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:[email protected]
