Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Hibernate: how to annotate Collection<Object> to allow searc
PostPosted: Sat Mar 05, 2016 12:47 am 
Newbie

Joined: Sat Mar 05, 2016 12:33 am
Posts: 2
Hi, I have a question regarding indexing Embedded Set<Object>.

Say I have a model A like this:
Code:
@Embeddable
class A {
    @Field
    private String name;
    @Field
    private Boolean editable;
    @IndexedEmbedded
    private B bObject;

    @ContainedIn
    @OneToMany
    @JoinColumn(name = "setOfA")
    private C forC;
}


where, B is, say
Code:
@Embeddable
class B {
    @Field
    private int intValue;
    @Field
    private boolean boolValue;
}


Now, I have a class C,
Code:
@Entity
class C {

    //How to annotate this to enable search like setOfA.name="searchQuery", or setOfA.bObject.intValue=5
    @ElementCollection
    private Set<A> setOfA;
}

Now how do I annotate setOfA to enable searches like setOfA.name="query", or setOfA.bObject.intValue=5.
I see that I can create custom Bridge, but can't figure out what the Bridge should do, specially to enable search like setOfA.bObject.intValue = 5.

I also asked this on stackoverflow, and got a suggestion to use @ContainedIn (http://stackoverflow.com/questions/3578 ... low-search), but that didn't work, getting
Code:
Caused by: org.hibernate.MappingException: Could not determine type for com.*.C, at table: C_setOfA, for columns: [org.hibernate.mapping.Column(setOfA.forC)]

I am posting here for better visibility, sorry if linking so is not allowed.

Any help is appreciated. Thanks.


Top
 Profile  
 
 Post subject: Re: Hibernate: how to annotate Collection<Object> to allow searc
PostPosted: Sat Mar 05, 2016 2:40 pm 
Newbie

Joined: Sat Mar 05, 2016 12:33 am
Posts: 2
Can anyone help me with this please?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.