Hi, am generally new on Hibernate and my task is to re-write a component written in Struts to Using hibernate + Spring. I have an fair background on hibernate configurations (Mapping using hbm.xml). But am wondering if its rather better to use EJB3_Hibernate annotations instead of the XML mappings since am not that experienced with Hibernate tools... Having said that, i have a specific questions on annotations.
My current POJOs are used to contain data copied from a form bean (struts). These objects can be made annotated to become persistent to my DB tables. But they do not have all the properties contained on the table. For an example, i have an object called Members
Code:
public abstract class Members implements java.io.Serializable {
private String initials;
private String surname;
private String force;
private String qualCode;
private String qualName;
public Members() {}
public Members(String initials, String surname, String force,
String qualCode, String qualName) {
super();
this.initials = initials;
this.surname = surname;
this.force = force;
this.qualCode = qualCode;
this.qualName = qualName;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getForce() {
return force;
}
public void setForce(String force) {
this.force = force;
}
public String getInitials() {
return initials;
}
public void setInitials(String initials) {
this.initials = initials;
}
public String getFullName() {
return force + " "
+ surname + ", "
+ initials;
}
public String getQualCode() {
return qualCode;
}
public void setQualCode(String qualCode) {
this.qualCode = qualCode;
}
public String getQualName() {
return qualName;
}
public void setQualName(String qualName) {
this.qualName = qualName;
}
}
/* HERE ... */
public class MembersDTO extends Members {
public MembersDTO() {
}
public MembersDTO(String initials, String surname, String force,
String qualCode, String qualName) {
super(initials, surname, force, qualCode, qualName);
}
}
But the actual table (MEMBERS) on the database has a lot more other properties and does not have few other properties included here (qualCode & qualName) ...
Q.
1. Is it a Requirement for a POJOs to be a persistent (using annotations/hbm.XML) to have ALL the properties in the DB table? Or by just adding @Column to only the matching properties this can still work?
2. As you can see, getFullName() doesn't return a property, would this be allowed in an entity bean?
3. Can an abstract class like i have be annotated? or should i do this on the child class MembersDTO?
Hope my questions are not confusing...