Hi,
I have set of domain classes that are persisted using an ObjectStore, but I want to provide the capability to store to a RDMS as well.
I've read through 15-20 tutorials on how to setup persistence, but I haven't been able to identify a strategy for persisting my model.
Model is as follows:
Code:
/*
* Facade for implementation of Active Record
*/
public class PersistableEntity {
public void save() {
PersistenceConfig.getPersistenceManager().save(this);
}
public void delete() {
PersistenceConfig.getPersistenceManager().delete(this);
}
}
Code:
public class TaggableEntity extends PersistableEntity {
protected List<MetaTag> metaTags = new ArrayList<MetaTag>();
public MetaTag addMetaTag(String type, String value) {
return addMetaTag(new MetaTag(type, value, this));
}
public MetaTag addMetaTag(MetaTag tag) {
metaTags.add(tag);
return tag;
}
public void addMetaTags(MetaTag[] metaTags) {
for (MetaTag metaTag : metaTags) {
addMetaTag(metaTag);
}
}
public void updateMetaTagAt(int index, String type, String value) {
metaTags.set(index, new MetaTag(type, value, this));
}
public void updateMetaTagAt(int index, MetaTag tag) {
metaTags.set(index, tag);
}
public boolean hasTag(MetaTag tag) {
return metaTags.contains(tag);
}
public boolean hasTags() {
return metaTags.size()>0;
}
public void clearMetaTags() {
for (MetaTag tag : metaTags) {
tag.delete();
}
metaTags.clear();
}
}
Code:
public class MetaTag extends TaggableEntity {
private String value = null;
private String type = null;
TaggableEntity parentEntity = null;
}
Code:
public class Resource extends TaggableEntity {
protected String type = null;
}
Any Suggestions on how this could be mapped to a RDMS, I've been taering my hair out for days now.
Thanks,
Vackar