How do I write a JPA criteria query that matches a collection exactly?

前端 未结 2 1157
挽巷
挽巷 2021-01-14 00:17

I’m using JPA 2.0 with Hibernate 4.1.0.Final. I have a couple of classes, Groups and GroupMembers. Each GroupMember is tied to a user object

@Entity
@Table         


        
2条回答
  •  走了就别回头了
    2021-01-14 00:39

    How about creating a procedure in SQL and calling the same using JPA? I created the following for calling login procedure I created.

        @Query(nativeQuery = true,value = "{call Login_User(:username,:pass)}")  // call stored procedure 
        int loginUser(@Param("username")String username,@Param("pass")String pass);
    

    And the SQL Procedure I had created was as following:

    DELIMITER //
    CREATE PROCEDURE Login_User(IN username CHAR(12), IN pass text(255))
    BEGIN
        DECLARE password text(18);
        SELECT User_Password INTO password  FROM user WHERE User_ID = username;
        select if(STRCMP(pass,password)= 0,1,0) as str_compare;
    END//
    DELIMITER ;
    

    Hope this helps. Cheers! I'm open to know more about the same. I know mine is more like a workaround rather than the solution :)

提交回复
热议问题