0

I have a table which name is "Pstn" and there is User table. Users does not have to use Pstn table. But some users can use it. So if a pstn has an user we want to see who is. How can i configure hibernate annotations?

 pstnBbkTable.setVisibleColumns(new Object[]{"pstn", "bbk", "user.firstName", "inReserve", "creationDate", "expireDate", "button"});

java.lang.IllegalArgumentException: Ids must exist in the Container or as a generated column, missing id: user.firstName at com.vaadin.ui.Table.setVisibleColumns(Table.java:691)

User table:

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "user_Id")
    private long userId;

    @Column(name = "username", nullable = false)
    private String username;

    @Column(name = "password", nullable = false)
    private String password;

    @Column(name = "first_name", nullable = false)
    private String firstName;

    @Column(name = "last_name", nullable = false)
    private String lastName;

Pstn Table:

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "pstn_Id")
    private long pstnId;

    @Column(name = "pstn")
    private String pstn;

    @Column(name = "bbk")
    private String bbk;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_Id")
    private User user;

********************* UPDATED SOLUTION ****************

I replaced pstn bean field like above. I think it occured because of FetchType.EAGER-Lazy..

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "user_Id")
    private User owner;
stephan
  • 271
  • 1
  • 4
  • 24
  • It's not really clear what relation you want between those 2 tables... If i got that right: one user can have zero or multiple Pstn? If so you want a nullable FK userId in the Pstn table – Zeromus Feb 06 '17 at 09:35
  • 1
    @Zeromus yes right, but when i try to list all pstn data, i got an error like above; java.lang.IllegalArgumentException: Ids must exist in the Container or as a generated column, missing id: user.firstName at com.vaadin.ui.Table.setVisibleColumns(Table.java:691) – stephan Feb 06 '17 at 09:40
  • never really used that method but shouldnt user.firstName be actually userId.firstName? Seems like it cant find that column – Zeromus Feb 06 '17 at 09:51

1 Answers1

0

I replaced pstn bean field like above. I think it occured because of FetchType.EAGER-Lazy..

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_Id")
private User owner;
stephan
  • 271
  • 1
  • 4
  • 24