hi,

i am new in Spring 3 MVC programming. I had wrote a Spring 3 MVC example with Hibernate.

This is the Class Diagram:

Bildschirmfoto 2011-11-16 um 下午8.25.38.jpg

There are the codes for person and company object:
Code:
@Entity
@DiscriminatorValue("COMPANY")
public class Company extends Customer {

	private static final long serialVersionUID = 1L;
	
	private String companyName;

	@Column(name = "company_name")
	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

}



@Entity
@DiscriminatorValue("PERSON")
public class Person extends Customer {
	
	private static final long serialVersionUID = 1L;
	
	private String prefix;
	private String firstName;
	private String middleName;
	private String lastName;
	private String title;
	private String gender;
	private Date dateOfBirth;

       //  getters and setters
      }
this is the code for object Customer:
Code:
@Entity
@Table(name = "customer")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "customer_type", discriminatorType = DiscriminatorType.STRING)
public class Customer implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private Long id;
	private String customerForeignId;
	private List<Contact> contacts;
	private Date creationDate;
	private String status;

        // getters and setters

       @OneToMany(fetch = FetchType.LAZY, 
			cascade = {CascadeType.ALL})
	@JoinTable(name = "customer_hat_contacts",
				joinColumns = {@JoinColumn(name = "customer_id")},
				inverseJoinColumns = {@JoinColumn(name = "contact_id")})
	public List<Contact> getContacts() {
		return contacts;
	}

       ...
       }

There are the codes for contact and the inherited classes
Code:
@Entity
@Table
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "contact_cat", discriminatorType = DiscriminatorType.STRING)
public abstract class Contact implements Serializable {

	private static final long serialVersionUID = 1L;

	private String id;
	private boolean isPrimary;
	private String contactType; // home, private, work, 24h
	private String notice;
	private Date createdDate;
        
        ...
       }

@Entity
@Table
@DiscriminatorValue(value = "EMAIL")
public class Email extends Contact {
	
	private static final long serialVersionUID = 1L;
	
	/*private long id;*/
	private String email;
       
      // getter and setter
}



@Entity
@Table
@DiscriminatorValue(value = "TELEPHONE")
public class Telephone extends Contact {
	
	private static final long serialVersionUID = 1L;
	
	//private long id;
	private String telephoneNumber;
	private String telephoneType; // Handy, Festnetz, Fax

       //getters and setters
}

......
My problems are:
1. how to list all Customers(person and company mixed) in one jsp page. there are two different subclass objects.
2. how to create a customer with contacts in one form?
3. Is Creating a ViewObject(FromObject) for different Customer a better way?