Re: [ebean] Double condition for relation

18 views
Skip to first unread message

Rob Bygrave

unread,
May 12, 2013, 5:12:17 PM5/12/13
to eb...@googlegroups.com
>> Of course it does not work, because it joins table attribute_value only 1 time (but I need double join).

You are correct, it won't work the way you want.

At this point you'll need to look at RawSql to work around this.


On 12 May 2013 18:50, Sergey Grigorchuk <sergey.g...@gmail.com> wrote:
Hi all,

I have two entity classes document and it's attribute values:

@Entity
public class Document extends Model{
...
  @OneToMany
  public List<AttributeValue> values;
...
}

@Entity
public class AttributeValue extends Model{
  String name;
  String value;
...
}

If I want to find all documents which has one attribute, e.g.:

type = passport 

I do:
find.where()
  .eq('values.name', 'type')
  .eq('values.value', 'passport')
.findList()
Everything is ok

But if I want to find all documents which has two attributes, e.g.:

type = passport
number = 4083069572

find.where()
  .eq('values.name', 'type')
  .eq('values.value', 'passport')
  .eq('values.name', 'number')
  .eq('values.value', '4083069572')
.findList()

Of course it does not work, because it joins table attribute_value only 1 time (but I need double join).

Any suggestions? Comments?

Thnx

--
 
---
You received this message because you are subscribed to the Google Groups "Ebean ORM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ebean+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages