code_junkie

Again with JPA not making sense

Nov 11th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. B sa_id(key) s_id user pwd.
  2.  
  3. @Entity class A...{
  4. @OneToMany(fetch=FetchType.EAGER)
  5. @JoinTable( name="A_B",
  6. joinColumns={@JoinColumn(name="a_id",
  7. table="a",unique=false)},
  8. inverseJoinColumns={@JoinColumn(name="b_id",
  9. table="b", unique=true)} ) Collection
  10. getB(){...} }
  11.  
  12. @Entity
  13. class A{
  14. ...
  15. @OneToMany(fetch=FetchType.EAGER, mappedBy="s")
  16. Collection<B> x;
  17. }
  18.  
  19. @Entity
  20. class B{
  21. @ManyToOne
  22. A s;
  23. }
  24.  
  25. With these tables:
  26. A
  27. s_id(key) name cli type
  28.  
  29. B
  30. sa_id(key) s_id(the keys from A) user pwd.
Add Comment
Please, Sign In to add comment