Skip to content

Commit

Permalink
https://issues.jboss.org/browse/RESTEASY-557
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/billburke/jboss/resteasy/resteasy-git/svn-server-sync/resteasy/branches/Branch_1_2@1372 2b1ed4c4-5db3-0410-90e4-80a7a6204c25
  • Loading branch information
liweinan committed Jun 10, 2011
1 parent 65dc530 commit a34bec6
Show file tree
Hide file tree
Showing 14 changed files with 305 additions and 526 deletions.
35 changes: 0 additions & 35 deletions examples/spring-hibernate-contacts/client/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -22,108 +22,93 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


/**
* @author <a href="mailto:obrand@yahoo.com">Olivier Brand</a>
* Jun 28, 2008
* @author <a href="mailto:obrand@yahoo.com">Olivier Brand</a> Jun 28, 2008
*
*/
@XmlRootElement(name = "contact")
@Entity
@Table(name = "Contact")
@Path("/")
public class Contact
{
private Long id;
private String name;
private String email;
private String telephone;
@XmlTransient
private Set<Contact> contactChildren;

public Contact() {

this.contactChildren = new LinkedHashSet<Contact>();
}

@GET
@Produces("application/xml")
@Transient
public Contact get()
{
return this;
}

@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@XmlAttribute(name = "contactId")
public Long getId()
{
return id;
}

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

@Column(name = "name")
public String getName()
{
return name;
}

public void setName(String name)
{
this.name = name;
}

@Column(name = "phone")
public String getTelephone()
{
return telephone;
}

public void setTelephone(String telephone)
{
this.telephone = telephone;
}

@Column(name = "email")
public String getEmail()
{
return email;
}

public void setEmail(String email)
{
this.email = email;
}

@ManyToMany(cascade = { CascadeType.ALL },fetch=FetchType.EAGER)
@JoinTable(name = "ContactToContactJoinTable", joinColumns = @JoinColumn(name = "parentContactId"), inverseJoinColumns = @JoinColumn(name = "childContactId"))
@XmlTransient
public Set<Contact> getContactChildren()
{
return contactChildren;
}

public void setContactChildren(Set<Contact> contactChildren)
{
this.contactChildren = contactChildren;
}

@GET
@Path("/contacts")
@Produces("application/xml")
@XmlTransient
@Transient
public Contacts getContacts()
{
Contacts contacts = new Contacts();
contacts.setContacts(getContactChildren());
return contacts;
}
public class Contact {
private Long id;
private String name;
private String email;
private String telephone;
@XmlTransient
private Set<Contact> contactChildren;

public Contact() {

this.contactChildren = new LinkedHashSet<Contact>();
}

@GET
@Produces("application/xml")
@Transient
public Contact get() {
return this;
}

@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@XmlAttribute(name = "contactId")
public Long getId() {
return id;
}

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

@Column(name = "name")
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Column(name = "phone")
public String getTelephone() {
return telephone;
}

public void setTelephone(String telephone) {
this.telephone = telephone;
}

@Column(name = "email")
public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

@ManyToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
@JoinTable(name = "ContactToContactJoinTable", joinColumns = @JoinColumn(name = "parentContactId"), inverseJoinColumns = @JoinColumn(name = "childContactId"))
@XmlTransient
public Set<Contact> getContactChildren() {
return contactChildren;
}

public void setContactChildren(Set<Contact> contactChildren) {
this.contactChildren = contactChildren;
}

@GET
@Path("/contacts")
@Produces("application/xml")
@XmlTransient
@Transient
public Contacts getContacts() {
Contacts contacts = new Contacts();
contacts.setContacts(getContactChildren());
return contacts;
}

}

0 comments on commit a34bec6

Please sign in to comment.