0

I am using hibernate 4.1.0,jpa 2.1.when i try putting a one to many relationship I get the error above. I have tried other solutions on stack-overflow but they don,t work for me

Here is my bean class:

@Entity
public class Users implements Serializable {

    @GeneratedValue(strategy = GenerationType.AUTO)
    @Id
    private int Id;
    private int orgId;
    private String salutation;
    private String firstName;
    private String lastName;
    private String email;
    private String telephone;
    private String universalRecordLocator;
    private String password;
    private String userLevel;

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "employee_id")
    UserRoles userRoles;

    public int getId() {
        return Id;
    }

    ...

bellow is the stack-trace:

Exception in thread "main" java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
Maxim
  • 9,701
  • 5
  • 60
  • 108
wndessy
  • 13
  • 6
  • 1
    Possible duplicate of [NoSuchMethodError only on Linux](http://stackoverflow.com/questions/24236521/nosuchmethoderror-only-on-linux) – Neil Stockton Apr 10 '16 at 12:12
  • Also dup of https://stackoverflow.com/questions/35701588/cant-create-entity-manager-when-add-relationships and many other questions, if only you'd searched ... – Neil Stockton Apr 10 '16 at 12:18

1 Answers1

1

It seems to me that you have a JPA API 1.0 jar in your runtime classpath as the orphanRemoval attribute got introduced in JPA 2.0 and the error you're getting means that the attribute itself is missing from the API version discovered at runtime, which should only happen in case of JPA 1.0. Check your runtime classpath.

Nándor Előd Fekete
  • 6,988
  • 1
  • 22
  • 47