gudii9
asked on
hibernate model object
I was going through below 2 ways of declaring model object
I did not understood the difference. Which one to use where and uses.
@Entity(name="USER_DETAILS ")
public class UserDetails {
private int userId;
@Id
then below
@Entity
@Table(name="USER_DETAILS" )
public class UserDetails {
private int userId;
@Id
Please advise. Any ideas, resources, sample code highly appreciated. thanks in advance
package org.gp.gpr.dto;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
//import org.hibernate.annotations.Entity;
@Entity(name="USER_DETAILS")
public class UserDetails {
private int userId;
@Id
@Column(name="USER_ID")
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
@Column(name="USER_NAME")
public String getUserName() {
return userName+"from get";
}
public void setUserName(String userName) {
this.userName = userName;
}
private String userName;
}
package org.gp.gpr.dto;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
//import org.hibernate.annotations.Entity;
@Entity
@Table(name="USER_DETAILS")
public class UserDetails {
private int userId;
@Id
@Column(name="USER_ID")
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
@Column(name="USER_NAME")
public String getUserName() {
return userName+"from get";
}
public void setUserName(String userName) {
this.userName = userName;
}
private String userName;
}
I did not understood the difference. Which one to use where and uses.
@Entity(name="USER_DETAILS
public class UserDetails {
private int userId;
@Id
then below
@Entity
@Table(name="USER_DETAILS"
public class UserDetails {
private int userId;
@Id
Please advise. Any ideas, resources, sample code highly appreciated. thanks in advance
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.