Hi all,
after searching the examples, documentation and forum for a solution I can't 
get the following use case to work:
I like to restrict the EntityQuery for object A by a related Object B. The 
Entities and search-dialogue are created by seam-gen. But I like to add a 
simple single select list of object of class b as search criteria.

My code:

  | @Entity
  | public class A implements Serializable
  | {
  |     @Id
  |     @GeneratedValue(strategy = GenerationType.AUTO)
  |     private Long                            id;
  | 
  |     @ManyToOne(fetch = FetchType.EAGER)
  |     @JoinColumn(name = "bid", nullable = true)
  |     private B                       b;
  | }
  | 
  | @Entity
  | public class B implements Serializable
  | {
  |     @Id
  |     @GeneratedValue(strategy = GenerationType.AUTO)
  |     private Long                            id;
  | 
  |     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy 
= "b")
  |     private Set<A> as;
  | }
  | 

I like to create an EntityQuery, which searches / returns Objects of class A 
related to a specific Object of class B. One of my tries looks as follows:

  | @Name("aList")
  | public class AList extends EntityQuery
  | {
  |     private static final String[]   RESTRICTIONS    = {
  |             "b = #{aList.a.b}", };
  | 
  |     @Override
  |     public String getEjbql()
  |     {
  |             return "select a from A as a join a.b as b";
  |     }
  | }
  | 
Which produces an error like:

  | Caused by: java.lang.IllegalArgumentException: argument type mismatch
  |     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |     at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  |     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |     at java.lang.reflect.Method.invoke(Method.java:597)
  |     at javax.el.BeanELResolver.setValue(BeanELResolver.java:108)
  |     ... 58 more
  | 


Another one like this:

  | @Name("aList")
  | public class AList extends EntityQuery
  | {
  |     private static final String[]   RESTRICTIONS    = {
  |             "a.b = #{aList.a.b}", };
  | 
  |     @Override
  |     public String getEjbql()
  |     {
  |             return "select a from A as a";
  |     }
  | }
  | 
Resolves in the same. In both cases, the query parameter is set properly to an 
object of class B.


What am I doing wrong? Or can just someone provide an example on how to 
restrict EntityQueries by @ManyToOne-related Entities?

Thanks for help,

Daniel

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4102557#4102557

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4102557
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to