-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Help With Mapping Stategy
PostPosted: Sun Aug 30, 2009 8:39 am 
Newbie

Joined: Sun Aug 30, 2009 8:26 am
Posts: 7
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


Top
 Profile  
 
 Post subject: Re: Help With Mapping Stategy
PostPosted: Mon Aug 31, 2009 4:29 am 
Newbie

Joined: Sun Aug 30, 2009 8:26 am
Posts: 7
Alternatively, does anyone know if there are hibernate tools to automatically create mapping for my domain classes?


Top
 Profile  
 
 Post subject: Re: Help With Mapping Stategy
PostPosted: Tue Sep 01, 2009 8:24 am 
Newbie

Joined: Sun Aug 30, 2009 8:26 am
Posts: 7
For anyone who is interested, I couldn't find a tool to do this.
Instead I annotated the classes and let the jpa implementation generate the tables etc - did need some tweaking to match business rules though.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.