hbm2java is not generating the @Version annotation for the <version ...> element

Description

See http://forum.hibernate.org/viewtopic.php?p=2310547#2310547

Given a mapping file:


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 13, 2006 3:27:21 PM by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="Sample" table="Sample">
<id name="id" type="java.lang.Long">
<column name="id" />
<generator class="native" />
</id>
<version name="version" column="version"/>
<property name="value" column="value" type="string"/>
</class>
</hibernate-mapping>


the following ejb is generated (via hbm2java, ejb3="true", jdk5="true":


// default package
// Generated Jun 16, 2006 3:23:35 PM by Hibernate Tools 3.1.0.beta5

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

/**

  • Sample generated by hbm2java
    */
    @Entity
    @Table(name="Sample"
    )
    public class Sample implements java.io.Serializable {

// Fields

private Long id;
private Integer version;
private String value;

// Constructors

/** default constructor */
public Sample() {
}

/** full constructor */
public Sample(String value) {
this.value = value;
}

// Property accessors
@Id @GeneratedValue

@Column(name="id", unique=false, nullable=false, insertable=true, updatable=true)
public Long getId() {
return this.id;
}

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

@Column(name="version", unique=false, nullable=false, insertable=true, updatable=true)
public Integer getVersion() {
return this.version;
}

public void setVersion(Integer version) {
this.version = version;
}

@Column(name="value", unique=false, nullable=true, insertable=true, updatable=true)
public String getValue() {
return this.value;
}

public void setValue(String value) {
this.value = value;
}
}


There should be a @Version annotation on the version property!

Environment

None

Attachments

1
  • 06 Feb 2007, 01:19 PM

is duplicated by

Activity

Show:

xsertyNFebruary 6, 2007 at 1:20 PM

Hi Max,
I have to admit: I never used junit or any kind of testing framework!
I tried having a look at tests already there, but couldn't really understand how to integrate validation for my code.
Hope you still appreciate the patch I've attached. BTW, please be aware that I'm a newbie so double check carefully my code!
If somebody ever submits a test case for this patch, I'd like to see it (for future reference!).
Kindest regards,
Stephen Longo

xsertyNFebruary 6, 2007 at 1:19 PM

Submitting patch for evaluation.
Kind regards,
Stephen Longo

Max Rydahl AndersenFebruary 6, 2007 at 11:25 AM

yes, extending/adding a junit test to validate gives extra karma points .

xsertyNFebruary 6, 2007 at 11:18 AM

Hi,
I have a patch for this bug and I'd like to submit it for evaluation.
How may I proceed? Do I just attach the file as an attachment to this JIRA?
Kind regards,
Stephen Longo

Max Rydahl AndersenOctober 17, 2006 at 6:38 PM

use forum.hibernate.org for usage questions.

Duplicate

Details

Assignee

Reporter

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

Eric Amram
Max Rydahl Andersen
SeanS
xsertyN

Components

Affects versions

Priority

Created June 16, 2006 at 9:25 PM
Updated June 4, 2007 at 3:00 PM
Resolved June 4, 2007 at 3:00 PM