> Thats why you have to use the <subclass> strategy instead of the
> <joined-subclass>. You have a discriminator value already, but keep in
> mind that this strategy has some problems, like impossibility of NOT
> NULL constraints.

Just to understand you...

Lets say my application wants to persist instances of 3 permission classes (all
of which subclass java.security.Permission in the hierarchy at some point):

java.io.FilePermission
com.my.PrinterPermission
com.my.URLPermission

Are you implying I need a <subclass> definition for each of the above 3 classes?
 Doesn't this mean there would be 3 tables created, one for each of them?

I was hoping that I could have just one hbm mapping definition for
java.security.Permission and define some utility class that tells hibernate
something like the following:

//for persistence:

if (thisObject instanceof java.security.Permission) {

java.security.Permission p = (Permission)thisObject;

UUID uuid = generator.getNewUUID();

//psuedo sql:
insert into permissions values (uuid.toString(), 
                                p.getClass().getName(), 
                                p.getName(), 
                                p.getActions());
}


extraction would work like this:
//after getting ResultSet rs:

java.security.Permission retrieved = (Permission)
Class.forName(rs.getString("class_name")).newInstance();
retrieved.setId(new UUID(rs.getString("id")));
retrieved.setName(rs.getString("target_name"));
retrieved.setActions(rs.getString("actions"));
return retrived;

Can I not create some class that tells Hibernate what values go in what columns
for persistence, and conversely for retrieval, what columns go in what values? 
Notice the Class.forName() dynamic approach is what makes this valuable to me...

I suppose I _could_ use a <subclass> mapping per class (if that is required),
but that doesn't make sense to me:  If I want to persist 15 different permission
types, there would be 15 tables created each defined with the exact same data
structure.  That seems excessive.  Or, is this just "one of those things" that
we see because of the awkward nature of OR mapping? (That and the
java.security.Permission class is a piece of CRAP in terms of OO design).

Thanks again,

Les


-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to