Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- @Table(name = "userEntity", schema = "public")
- public class UsersEntity implements java.io.Serializable{
- private Integer userId;
- private String name;
- private Integer date;
- private String username;
- private String phone;
- private String email;
- private String password;
- private String country;
- private Set<Stock> stock = new HashSet<Stock>(
- 0);
- public UsersEntity() {
- }
- public UsersEntity(Integer userId, String name, Integer date, String username,
- String phone, String email, String password, String country,
- Set<Stock> stock) {
- this.userId = userId;
- this.name = name;
- this.date = date;
- this.username = username;
- this.phone = phone;
- this.email = email;
- this.password = password;
- this.country = country;
- this.stock = stock;
- }
- @Column(name = "name", nullable = true, length = 255)
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- @Id
- @Column(name = "userId")
- @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "user_seq_gen")
- @SequenceGenerator(name = "user_seq_gen", sequenceName = "user_id_seq")
- public Integer getUserId() {
- return userId;
- }
- public void setUserId(Integer userId) {
- this.userId = userId;
- }
- @Column(name = "date", nullable = true, length = 255)
- public Integer getDate() {
- return date;
- }
- public void setDate(Integer date) {
- this.date = date;
- }
- @Column(name = "username", nullable = true, length = 255)
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- @Column(name = "phone", nullable = true, length = 255)
- public String getPhone() {
- return phone;
- }
- public void setPhone(String phone) {
- this.phone = phone;
- }
- @Column(name = "email", nullable = true, length = 255)
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- @Column(name = "password", nullable = true, length = 255)
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- @Column(name = "country", nullable = true, length = 255)
- public String getCountry() {
- return country;
- }
- public void setCountry(String country) {
- this.country = country;
- }
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "userEntity")
- public Set<Stock> getStock() {
- return this.stock;
- }
- public void setStock(Set<Stock> stock) {
- this.stock = stock;
- }
- @Entity
- @Table(name = "stock", schema = "public")
- public class Stock {
- private int id;
- private String description;
- private UsersEntity usersEntity;
- public Stock() {
- }
- public Stock(int id, String description) {
- this.id = id;
- this.description = description;
- }
- @Id
- @GeneratedValue(strategy = IDENTITY)
- @Column(name = "id", unique = true, nullable = false)
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- @Column(nullable = true, length = 255)
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "userId", nullable = false)
- public UsersEntity getUser() {
- return this.usersEntity;
- }
- public void setUser(UsersEntity usersEntity) {
- this.usersEntity = usersEntity;
- }
- <hibernate-configuration>
- <session-factory>
- <property name="hbm2ddl.auto">create</property>
- <property name="connection.url">jdbc:postgresql://localhost:5432/personal2</property>
- <property name="connection.username">postgres</property>
- <property name="connection.password">root</property>
- <property name="connection.driver_class">org.postgresql.Driver</property>
- <mapping class="Entity.UsersEntity"/>
- <mapping class="Entity.Stock"/>
- org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: Entity.Stock.userEntity in Entity.UsersEntity.stock
Add Comment
Please, Sign In to add comment