How to work with interfaces and JPA

前端 未结 1 1556
眼角桃花
眼角桃花 2021-02-04 03:21

I should start out by saying that I am fairly new to Java EE and that I do not have a strong theoretical background in Java yet.

I\'m having trouble grasping how to use

相关标签:
1条回答
  • 2021-02-04 03:43

    You can use targetEntity property in the relationship annotation.

    @Entity
    public class PersonEntity implements Person {
        private Long id;
    
        private Pet pet;
    
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        public Long getId() {
            return id;
        }
    
        public void setId(Long id) {
            this.id = id;
        }
    
        @Override
        @OneToOne(targetEntity = PetEntity.class)
        public Pet getPet() {
            return pet;
        }        
    
        public void setPet(Pet pet) {
            this.pet = pet;
        }
    }
    
    0 讨论(0)
提交回复
热议问题