Need help with Composite Key as primary Key

classic Classic list List threaded Threaded
4 messages Options
himanshu himanshu
Reply | Threaded
Open this post in threaded view
|

Need help with Composite Key as primary Key

Hi Team,

I have a table with following model

public class Employee implements Serializable {

    private static final long serialVersionUID = -1271194616130404625L;

    @QuerySqlField(index = true)
    private EmployeePK pk;

    @QuerySqlField(index = true)
    private Long qty1;

    @QuerySqlField(index = true)
    private Long qty2;

    @QuerySqlField(index = true)
    private Long qty3;

    private Long qty4;
    private Long qty5;
    private Long qty6;
}

public class EmployeePK implements Serializable {

    private static final long serialVersionUID = -1271194616130404625L;

//    @QuerySqlField(index = true)
    private String sku;

//    @QuerySqlField(index = true)
    private String store;

I am using spring ignite data when I am doing repository.findOne and try to
get result ReadThrough is not working for me. when I put PK attributes in
employee model it works but then I can not read through by sku and store

ANy help appreciated
}



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
himanshu himanshu
Reply | Threaded
Open this post in threaded view
|

Re: Need help with Composite Key as primary Key

I update my configuration as following and it is working but I am getting
class cast exception

public class Employee implements Serializable {

    private static final long serialVersionUID = -1271194616130404625L;
   
    private transient EmployeePK key;
   
    private String sku;

    private String store;
   
    @QuerySqlField(index = true)
    private Long qty1;

    @QuerySqlField(index = true)
    private Long qty2;

    @QuerySqlField(index = true)
    private Long qty3;

    private Long qty4;
    private Long qty5;
    private Long qty6;

}


public class EmployeePK implements Serializable {

    private static final long serialVersionUID = -1271194616130404625L;

    @QuerySqlField(index = true)
    private String sku;

    @QuerySqlField(index = true)
    private String store;

}


*java.lang.ClassCastException: com.ignite.demo.models.Employee cannot be
cast to com.ignite.demo.models.Employee*



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
himanshu himanshu
Reply | Threaded
Open this post in threaded view
|

Re: Need help with Composite Key as primary Key

In reply to this post by himanshu
please find sample code attached. any help appreciated. compositekey.zip
<http://apache-ignite-users.70518.x6.nabble.com/file/t2372/compositekey.zip>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
himanshu himanshu
Reply | Threaded
Open this post in threaded view
|

Re: Need help with Composite Key as primary Key

I am able to solve this issue, it was because of devtools jar in classpath in
my spring boot project, it was causing classpath conflict issues



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/