0

I Have Some Question that like title.

There is some Object with JPA (hibernate).

@Data
public class A {
    private String id;
    private String content;
    ...
    @ManyToOne(targetEntity = B.class)
    private B b;
}

@Data
public class B {
    private String id;
    private String content;
}

But that code is occur error 'MappingException'.

if i change to class A like this,

@Data
public class A {
    private String id;
    private String content;
    ...
    private B b;
    ...

    // Other field is generated by lombok
    @ManyToOne(targetEntity = B.class)
    public B getB() {
        return b;
    }
}

It works very clearly.. I don't understand different between this two way. Anyone know about this situation?

JKLee
  • 89
  • 9

0 Answers0