-->
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.  [ 2 posts ] 
Author Message
 Post subject: index DTYPE, @IndexEmbedded with @Inheritance
PostPosted: Wed Feb 04, 2009 5:15 pm 
Newbie

Joined: Wed Feb 04, 2009 7:27 am
Posts: 3
I have the following 3 classes

Code:
@Inheritance(strategy= InheritanceType.JOINED)
@Indexed
class Role {
   @DocumentId @Generated
   Integer id;
}

@Indexed
class Admin extends Role {
}
@Indexed
class NoBody extends Role {
}
@Indexed
class User {
    @IndexEmbedded
    Set<Role> roles = new HashSet<Role>();
}


If i persist a User with some Roles only the Role.id will be available in the Lucene-Document as 'roles.id'.
How can the discriminator value (default: column DTYPE) be included in the User-Document e.g. roles.dtype: Admin, Nobody ??

Thanks
mj


Top
 Profile  
 
 Post subject: Re: index DTYPE, @IndexEmbedded with @Inheritance
PostPosted: Wed Feb 04, 2009 5:37 pm 
Newbie

Joined: Wed Feb 04, 2009 7:27 am
Posts: 3
I was wrong....
InheritanceType.JOINED does not create a DTYPE column at, since each Entitiy has its own table.

Solution: Adding a simple String field to class Role initialized by Subclasses.

Code:
..
abstract class Role {
   ...
   @Field
   String type = getType();
   protected abstract String getType(); 
}
class Admin extends Role {
    protected String getType() {return "Admin"} 
}
class NoBody extends Role {
    protected String getType() {return "NoBody"} 
}


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