-->
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.  [ 6 posts ] 
Author Message
 Post subject: how to persistent mixin-ed object
PostPosted: Sun Apr 18, 2004 12:25 pm 
Newbie

Joined: Sun Apr 18, 2004 11:20 am
Posts: 3
hi all,

I use apectwerkz as aop framework to build pure mixin implementation for domain objects.
so that, We have Person.class mixin with Identifiable and HasName Interface/Implement:


Code:
Public class Person {
}


Code:
public interface Identifiable {
   public void setId(Serializable id);
   public Serializable getId();
}



Code:
public class IdentifiableImpl implements Identifiable {

   Serializable _id;
   public void setId(Serializable id) {
      _id = id;
   }
   public Serializable getId() {
      return _id;
   }
}


Code:
public interface HasName {
   public void setName(String name);
   public String getName();
}


Code:
public class HasNameImpl implements HasName {
   String _name;
   public void setName(String name) {
      _name = name;
   }
   public String getName() {
      return _name;
   }
}

Code:
Table Person:
column id String
column name String


when we build the person object use following:
Code:
Person p = new Person();
((Identifiable)p).setId("abc");
((HasName)p).setName("xyz");
....


The question is how to persistent the person object to database via Hibernate?
If it's possible, please give me a hint

Thanks for help!

yiming wang
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2004 2:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes - as long as you can somehow provide a name for your mixed-in class.

I don't know much about aspectworkz but I would expect for any decent class-generating framework, to be able to control/assure a consistent naming of the class.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2004 3:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
....and that name you simply put in as the class you want mapped...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2004 9:35 pm 
Newbie

Joined: Sun Apr 18, 2004 11:20 am
Posts: 3
max wrote:
....and that name you simply put in as the class you want mapped...


your meaning that i may only create the mapping xml file for that class (person.class), what about the properties mapping to the table's column?
More detail explains are appreciated
thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 3:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
As I understand it you are generating a class that are BOTH a Person and Identifiable - something like a IdentifiablePerson ...then you should name your class "IdentifiablePerson" and refer to that in the hbm.xml file..

Code:
<class name="IdentifiablePerson">
...
</class>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 10:55 am 
Newbie

Joined: Sun Apr 18, 2004 11:20 am
Posts: 3
I tried it out, but the question from "how to" become "Why can"?
I wrote it down in my weblog, here is the link:

http://www.jroller.com/page/ymwang/20040420#persistent_mixin_object_via_hibernate

and thanks again!

yiming wang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.