java - HQL Parameter not in Attribute -


i have 2 entities manytomany relation.

role core:

@entity @table(name = "role") public class rolecore extends baseentity {      @id     @generatedvalue(strategy = generationtype.auto, generator = "role_seq_gen")     @sequencegenerator(name = "role_seq_gen", sequencename = "role_seq", initialvalue = 100, allocationsize = 1)     @column(name = "role_id", nullable = false)     private long id;      @column(name = "name", length = 255)     private string name;      @column(name = "is_admin")     private short isadmin;      @manytomany     @jointable(inversejoincolumns = @joincolumn(name = "fk_right", referencedcolumnname = "right_id"),             joincolumns = @joincolumn(name = "fk_role", referencedcolumnname = "role_id"))     private list<rightcore> rights; } 

right core:

@entity @table(name = "right") public class rightcore extends baseentity {      @id     @generatedvalue(strategy = generationtype.auto, generator = "right_seq_gen")     @sequencegenerator(name = "right_seq_gen", sequencename = "right_seq", initialvalue = 100, allocationsize = 1)     @column(name = "right_id", nullable = false)     private long id;      @column(name = "token", length = 255)     private string token;      @column(name = "name_d", length = 255)     private string named;      @column(name = "name_f", length = 255)     private string namef;      @column(name = "name_i", length = 255)     private string namei;      @column(name = "is_admin")     private short isadmin;      @manytomany(mappedby = "rights")     private collection<rolecore> roles; } 

now want every rightcore isn't set 1 rolecore. tried 2 following statements , both throw ajava.sql.sqlsyntaxerrorexception:"ora-00936: missing expression"

public interface rightcoredao extends jparepository<rightcore, long> {      @query("select r rightcore r :role not in (r.roles)")     list<rightcore> findbyrolenotinandcategory(             @param("role") rolecore role);      @query("select r rightcore r r not in (:rights)")     list<rightcore> findbyrightsnotinandcategory(             @param("rights") list<rightcore> role); } 

edit: how call methods:

    @service        @transactional       public class authorizationdataservice {      @autowired     rightcoredao rightcoredao;      public list<rightcore> loadavailablerights1(rolecore role) {         return rightcoredao.findbyrolenotinandcategory(role);     }      public list<rightcore> loadavailablerights2(rolecore role) {         return rightcoredao.findbyrightsnotinandcategory(role.getrights());     } } 

what doing wrong , how can make 1 of these statements work?

sarajog

idhope understood question correctly , think looking :

to rightcores isn't set atleast single rolecore (means find rightcores roles empty) need have query below:

select r rightcore r r.roles empty; 

edit:

ok, after reading comment should have query similar to:

select rc rightcore rc rc.id not in ( select ro.rights.id rolecore ro ro.id=:role_id ) 

edit2:

select ri rights ri ri.id not in( select rs.id roles ro join ro.rights rs ro.id=:role_id ) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -