Hibernate mapping for Event bean using annotation method

Hi,
In our application scenario we extended DHXEvent object(class) as per sample given on JavaPlanner website.
We want to do hibernate mapping of our custom event class like following way.

@Entity
@Table(name = "Events")
@AttributeOverrides({
	 @AttributeOverride(name="id", column = @Column(name="event_id")),
	 @AttributeOverride(name="start_date", column = @Column(name="start_date")),
	 @AttributeOverride(name="end_date", column = @Column(name="end_date")),
	 @AttributeOverride(name="text", column = @Column(name="text"))
})
public class Event extends DHXEvent implements Serializable   {

}

I’m new to hibernate and Spring MVC, Please help us to figure out things.
Thanks

Means
I have to perform hibernate mapping only by using annotation method in subclass according to following scenario in Spirng MVC3 enviroment:

  1. I have class called Event.java from xxxx.jar library with following properties

public Class DHXEvent{ public integer id; public String start_date; public String start_date; public String text; }

  1. POJO class CustomEvent.java extending Event.java class using inheritance with following structure.

[code]public class CustomEvent extends DHXEvent implements Serializable {

private static final long serialVersionUID = 1L;

public String user;
public String type;
public String contact;
public String status;

}[/code]

  1. As per sample code Im able to perform hibernate mapping using XML in following way

<hibernate-mapping> <class name="<package>.model.CustomEvent" table="events"> <id column="event_id" name="id" type="java.lang.Integer"> <generator class="increment"/> </id> <property column="start_date" name="start_date" type="timestamp"/> <property column="end_date" name="end_date" type="timestamp"/> <property column="text" name="text" type="java.lang.String"/> <property column="user" name="user" type="java.lang.String"/> <property column="type" name="type" type="java.lang.String"/> <property column="contact" name="contact" type="java.lang.String"/> <property column="status" name="status" type="java.lang.String"/> </class> </hibernate-mapping>
and its working fine.

Q) How I can achieve the same thing with JPA/Hibernate annotations?

I am new bay for Hibernate / Spring framework.

Note: DHXEvent class is present in .jar library, not able to see the code exactly

Hello,
sorry for the delay in answerring.
You should override all required fields. Here is an example:

@Entity
@Table(name = "events_units")
public class EventTest extends DHXEvent {

        // overriding default fields

	@Id @Column(name = "event_id")
	public Integer id;
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(name = "text")
	public String text;
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	
	@Column(name = "start_date", columnDefinition = "timestamp")
	public Date start_date;
	public Date getStart_date() {
		return start_date;
	}
	public void setStart_date(Date start_date) {
		this.start_date = start_date;
	}
	
	@Column(name = "end_date", columnDefinition = "timestamp")
	public Date end_date;
	public Date getEnd_date() {
		return end_date;
	}
	public void setEnd_date(Date end_date) {
		this.end_date = end_date;
	}

        // your fields are here
	@Column(name = "user")
	public String user;

	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}

       // another fields
}

hey really Thanks :slight_smile: