-->
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.  [ 8 posts ] 
Author Message
 Post subject: Help implementing my object model
PostPosted: Wed Feb 01, 2006 9:00 pm 
Newbie

Joined: Wed Feb 01, 2006 8:07 pm
Posts: 4
Hi all,

I'm trying to implement my object model exclusively using EJB3/Hibernate annotations. I want to define a base class that indicates associations, permissions, etc and have all my domain entities extend it.

It would look something like this:

Code:
Interface ZObject
    |
abstract class BaseZObject implements ZObject
    |
class SomeZObject extends BaseZObject


Code:
public abstract class BaseZObject implements ZObject {
        @Keyword(id=true)
        public void setId(Long inid) { // see #1 below
            id = inid;
        }

   @ManyToMany(cascade = {CascadeType.PERSIST})   
   public Set<ZClassification> getZClassifications() {
      return classifications;
   }
//...
}

public class ZClassification extends BaseZObject {

    @ManyToMany(mappedBy="classifications")
    public Set<BaseZObject> getBaseZObjects() { // see #2
        return zobjects;
    }
//    ...
}

public class SomeZObject extends BaseZObject {
    @Column (length = 60)
    public String getSomfield {
        return somedata;
    }
//    ...
}


(Sorry if the above isn't quite right, I hope you get the idea).

However, I encounter issues..

#1 I can't seem to implement ID details in the base abstract class or interface. I get "no identifier specified" for SomeZObject.

#2 the classifications mapping fails with "Collection of elements must not have mappedBy or association reference an unmapped entity: baseZObjects" - This would evidently be because BaseZObject is not mapped, but I don't want to map my base class, but rather implementations of it.

I've also tried permutations adding the annotations in the interface rather than base class, but nothing has worked.

I'd like to try to implement this quickly for a prototype, or I'll have to go back to "the old ways." Does anyone have any advice? I'm open to commercial remote consulting/mentoring.

Thanks!

David


Top
 Profile  
 
 Post subject: Re: Help implementing my object model
PostPosted: Wed Feb 01, 2006 9:23 pm 
Newbie

Joined: Tue Apr 19, 2005 7:36 pm
Posts: 9
Location: San Francisco, CA
David,

You will need @EmbeddableSuperclass annotation on the base class, so that ID field can be inherited by the subclasses.

As far as the mapping to classifications, this is what it say in the docs:

You cannot use association annotations in an embeddable object (ie no @*ToOne nor @*ToMany). This is disallowed by the spec, and not yet supported in Hibernate Annotations.

See http://www.hibernate.org/hib_docs/annot ... tml#d0e485

_________________
Thanks,
Zeel.

Software Developer, Audiologist/DJ, Cookie Monster
All Original Electronic Music - download MP3s:
=> http://www.polygroovers.com/


Top
 Profile  
 
 Post subject: Re: Help implementing my object model
PostPosted: Thu Feb 02, 2006 10:35 am 
Newbie

Joined: Wed Feb 01, 2006 8:07 pm
Posts: 4
Thanks djzeel. That got me through a few problems. I think what I'm trying to accomplish is pretty straightforward, but see there's a whole lot of hibernate/ejb3 knowledge to pick up to complete the basics.

I'll have to go back to the old ways for now. If you or anyone is interested in a casual gig to help me upgrade, please let me know.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 1:21 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The annotations knowledge you're refering to is 95% shared from the hbm file knowledge. I don't understand your issues.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 1:26 pm 
Newbie

Joined: Wed Feb 01, 2006 8:07 pm
Posts: 4
emmanuel wrote:
The annotations knowledge you're refering to is 95% shared from the hbm file knowledge. I don't understand your issues.


Sorry, I don't know what you mean by "the hbm file knowledge."

As I was tried to outline in my message, I was hoping for a quick initial implementation, however since specific research is involved for the Hibernate/EJB3 part of my design, I've had to put it of, though I'd still like to track down someone to help get this off the ground quickly so I can switch my development.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 2:55 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
i was refering hibernate xml metadata

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 3:06 pm 
Newbie

Joined: Wed Feb 01, 2006 8:07 pm
Posts: 4
emmanuel wrote:
i was refering hibernate xml metadata


Sorry if I'm misunderstanding here, since your responses are a bit terse, but the point of my post was to discover how to do this through annotations.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 9:38 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Yes, when I'm in answering machine mode, I minimize the number of key to press :-)

For my inderstanding, you asked a question, Zeel answered you but then fall into new problems and complaining about the minimal step to go for annotations. So I answered this assumption.

_________________
Emmanuel


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