Quote:
The helper method is actually not a bad idea - if you want to keep your code clean you can use a custom PropertyAccssor which transforms to/from a Set/Map
I've added the helper method and added a set to the mapping file, and it appears to work fine. I probably should not worry so much about the helper method, i just get a little anal sometimes. It's just that i've got a bunch of engineers who will use any methods that exist, and then i have to live with them. As it is, i've had to add helper methods to handle marshalling and unmarshalling our whole domain so we can distribute our objects using SOAP/XML. So I suppose i've already moved in that direction, but i'm constantly trying to find ways to get rid of these helper methods, and not add new ones.
I will look into the custom PropertyAccessor to see if that will help me out.
Quote:
Can you reformulate your problem
I haven't really understand it. (post a simple POJO model)
I'd be happy to, thank you for taking the time and interest to read my post. I've cut these way way back. The Client that i use has many many attributes and lists of contacts, etc etc. However, for now, i'm interested in the PrivPlan. Basically PrivPlan is a set of integers. So, really i need to be able to store and retrieve a set of integers for this given clientid. Presumably it would be a separate table with PartyID,FeatureID as a key.
The mapping file below assumes that i add a method in SmallClient basically like below where the set will contain the collection of integers.
Code:
public Set getPrivs();
public void setPrivs(Set privs);
However, I was wondering how to this without adding a helper method in SmallClient that returns a List or Set of integers.
Code:
public class SmallClient {
private String Name;
private PrivPlan privilegePlan;
private long ClientID;
public void setPrivilegePlan(PrivPlan privilegePlan) {
this.privilegePlan = privilegePlan;
}
public void setClientID(long ClientID) {
this.ClientID = ClientID;
}
public PrivPlan getPrivilegePlan() {
return privilegePlan;
}
public long getClientID() {
return ClientID;
}
public void setName(String Name) {
this.Name = Name;
}
public String getName() {
return Name;
}
public class PrivPlan {
private Set featurePriv = Collections.synchronizedSet(new HashSet());
public PrivPlan() {
}
public void addPrivilege(int featureID){
featurePriv.add(new Integer(featureID));
}
public void removePrivilege(int featureID){
featurePriv.remove(new Integer(featureID));
}
public void clearPrivilegePlan(){
featurePriv.clear();
}
public boolean isPrivileged(int featureID){
return featurePriv.contains(new Integer(featureID));
}
}
The Mapping File for SmallClient:
<subclass name="SmallClient" discriminator-value="SmallClient">
<property name="name" />
</array>
<set name="privs" table="CLIENT_PRIVS">
<key column="PartyID"/>
<element column="FeatureID" type="integer"/>
</set>
</subclass>
This is all very helpful. I actually have what i think is a similar problem to solve next. A "FeePlan". In this case i have a collection of FeeObjects that have several attributes to them. Amount, Feature, Category. This collection is also tied to the Client. I'm looking mapping it using a set with composite-element within it. Hoping that that will do the trick for me.
Again, thanks to both of you for your help.