[hibernate-issues] [Hibernate-JIRA] Commented: (HBX-265) dynamicUpdate property in Entity annotation not work

radha mohan maheshwari (JIRA) noreply at atlassian.com
Sat Nov 26 12:06:20 EST 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HBX-265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44438#comment-44438 ] 

radha mohan maheshwari commented on HBX-265:
--------------------------------------------

I have same Problem.





@Entity
@Table(name="Student")
@org.hibernate.annotations.Entity(dynamicUpdate=true,dynamicInsert=true)
public class Student {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="ID")
	private int id;
	
	@Column(name="NAME" )
	  
	private String name;
	@ManyToOne(cascade=CascadeType.ALL, targetEntity =Course.class,fetch=FetchType.LAZY)
	@JoinColumn(name="COURSEID")
	private Course course;
	
	public Student(){
		
	}
	
	public Student(int id, String name, Course course) {
		
		this.id = id;
		this.name = name;
		this.course = course;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Course getCourse() {
		return course;
	}
	public void setCourse(Course course) {
		this.course = course;
	}
	@Override
	public String toString() {
		return "Student [id=" + id + ", name=" + name + ", course=" + course
				+ "]";
	}
	
	
	

}



@Entity
@Table (name="courses")
@org.hibernate.annotations.Entity(dynamicUpdate=true)
public class Course implements java.io.Serializable {
	
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue
	@Column(name="ID")
	private long id;
	@Column(name="name")
	private String name;

	public Course() {
	}

	public Course(String courseName) {
		this.name = courseName;
	}

	public Course(int id, String name) {
		this.id = id;
		this.name = name;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	@Override
	public String toString() {
		return "Course [id=" + id + ", name=" + name + "]";
	}
	
}




Student student = new Student();
	student.setId(1);
	session.update(student);

I am new with hibernate.plz give helping hand regarding same.
thanks in advance


> dynamicUpdate property in Entity annotation not work
> ----------------------------------------------------
>
>                 Key: HBX-265
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-265
>             Project: Hibernate Tools
>          Issue Type: Bug
>          Components: annotations (obsolete)
>    Affects Versions: 3.0beta1
>         Environment: Hibernate 3 hibernate annotations 3.0 beta1
>            Reporter: Rogerio Saulo
>             Fix For: 3.0beta2
>
>
> The property dynamicUpdate when set on the Entity annotation does not remove NULL columns from the UPDATE statement.
> For the dynamicInsert it is working.
> Below is my POJO, code to execute and generated UPDATE Statement.
> POJO :
> ------------------------------------------------------------------
> @Entity
> @org.hibernate.annotations.Entity ( dynamicInsert = true, dynamicUpdate = true )
> @Table (name = "USERS")
> @javax.persistence.GeneratedIdTable(
> 		name="GEN_TABLE",
> 		table = @Table(name="VENUS_IDS"),
> 		pkColumnName = "KEY_ID",
> 		valueColumnName = "LAST_VALUE"
> 	)
> @javax.persistence.TableGenerator(
> 	    name="USERS_GEN",
> 	    tableName="GEN_TABLE",
> 	    pkColumnValue="ID_USER",
> 	    allocationSize=1
> 	)
> public class UserVO implements Serializable {
> 	
> 	private Integer id_user;
> 	private String login;
> 	private String email;
> 	private String passwd;
> 	private Timestamp creation_timestamp;
> 	private Timestamp last_change_timestamp;
> 	
> 	@Column (name = "creation_timestamp")
> 	public Timestamp getCreation_timestamp() {
> 		return creation_timestamp;
> 	}
> 	@Column (name = "email")
> 	public String getEmail() {
> 		return email;
> 	}
> 	@Id (generate=GeneratorType.TABLE, generator="USERS_GEN")
> 	public Integer getId_user() {
> 		return id_user;
> 	}
> 	@Column (name = "last_change_timestamp")
> 	public Timestamp getLast_change_timestamp() {
> 		return last_change_timestamp;
> 	}
> 	@Column (name = "login")
> 	public String getLogin() {
> 		return login;
> 	}
> 	@Column (name = "passwd")
> 	public String getPasswd() {
> 		return passwd;
> 	}
>    .... (Setters come here)
> }
> --------------------------------------------------------------------
> Code executing :
> --------------------------------------------------------------------
>     UserVO obj = new UserVO();
>     obj.setId_user(new Integer(1));
>     obj.setEmail("alterado at teste.com");
> 			
>     session.update(obj);
> --------------------------------------------------------------------
> Generated update statement :
> Hibernate: update USERS set creation_timestamp=?, last_change_timestamp=?, email=?, login=?, passwd=? where id_user=?
> --------------------------------------------------------------------
> Thanks in advance.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list