Home find an entity using a class Id
Reply: 0

find an entity using a class Id

user898 Published in March 21, 2018, 8:48 am

To find an object from entity with primary key we use em.find(Person.class, <Id>).

I'm using JPA EclipseLink and I have a Person entity wich has a composite primary key(@classId),

the Person entity:

    public class Person {

private int id;

private String name;

public String getName() {
    return name;

// getters & setters

and PersonID:

public class PersonId implements Serializable {

private static final long idVersionUID = 343L;

private int id;
private String name;

// must have a default construcot
public PersonId() {


public PersonId(int id, String name) {
    this.id = id;
    this.name = name;

//getters & setters
//hachCode & equals

How to use em.find to get a specified Person object?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.2976 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO