--- Aapo Laakkonen <[EMAIL PROTECTED]> wrote: > > I'm crossposting this to xdoclet-devel... > > Ok, but wait! This is not so easy to solve as I > first thought. > > I attached examples: > - User.java (User Interface) > - UserImpl.java (User implementation that Hibernate > should use) > > What I'm after is that I should not have to know > UserImpl in anywhere in > my code, expect when I'm creating a new User to db.
Well, I follow a slightly different approach - I have complete separation of interface / implementation, and DAO class which manages creation/maniupulation and whatever necessary. I'm doing content management /redaction system , and like to be in complete control over what happens. So I have interfaces like Information / Version / Content / Attributed / Keyworded - which describe my content, and implementation classes which are hidden in separate package and are not public at all. Manager takes over creation and manipulation of objects. This way I'm not bound to talk with people developing frontends about database representation. Hey, they are not in position to see database identifiers :) So they can create "user" , but they do not care what implementation if back there. > As you see, I use User.class to load object. That > doesn't work, because > the mapping is written for UserImpl ('cause it's the > only possibility). > Well, you map class, you shall call it by name :) > Now I'm asking Gavin about why does Hibernate need > concrete > implementation class? Hibernate already can generate > proxy classes based > on interface, then would it be possible to provide > this same support for > persistent classes altogether and make hibernate > only to care about > interfaces (of course current concrete class support > should also be > provided). Actually you are not asking gavin, because you send email to me directly :) HIbernate needs conncrete implementation classes, because it got to instantiate them. OK, you could rig up some mock up with BCEL on the fly, or use proxy + interface - but normally you will use your pojo not only for data storage, but also some bit of business logic ( say, lifecycle stuff, which clearly belongs there ) > > What shall we do with subclasses? > > What do you mean? You may have noticed, that hibernate supports polymorphic mappings . I use them for content Every information version has content ( 1-1 mapping ), and content is of base class Content, and concreate subclasses are TextContent , BinaryContent or whatever - they all live in the same table. Though not necessary 5th normal form, but way easier to manage. And version.getContent() alvays delivers correct type... To be mapped, such polymorphic subclasses shall be actual subclasses of base class. It would be PITA to do this with interfaces... regards, ===== ----[ Konstantin Pribluda ( ko5tik ) ]---------------- Zu Verstärkung meines Teams suche ich ab Sofort einen Softwareentwickler[In] für die Festanstellung. Arbeitsort: Mainz Skills: Programieren, Kentnisse in OpenSource-Bereich ----[ http://www.pribluda.de ]------------------------ __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel