Skip to content

Instantly share code, notes, and snippets.

@nemo83
nemo83 / SimpleSpringTest.java
Created March 30, 2013 09:44
This is a simple test gists
import com.sun.jersey.spi.spring.container.servlet.SpringServlet;
import com.sun.jersey.test.framework.AppDescriptor;
import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.WebAppDescriptor;
import org.junit.Test;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.request.RequestContextListener;
import javax.ws.rs.core.MediaType;
@nemo83
nemo83 / Hello World.java
Created March 30, 2013 10:07
This is a Hello Wolrd Gist for my Blog so to advertise how good gist is!
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
@Entity
public class Employee {
@Id
private long id;
...
@OneToMany
private List<ProjectAssociation> projects;
}
@Entity
public class Project {
@Id
private long id;
...
@OneToMany
private List<ProjectAssociation> employees;
...
// Add an employee to the project.
@Entity
@Table(name="PROJ_EMP")
@IdClass(ProjectAssociationId.class)
public class ProjectAssociation {
@Id
private long employeeId;
@Id
private long projectId;
@Column("IS_PROJECT_LEAD")
private boolean isProjectLead;
public class ProjectAssociationId {
private long employeeId;
private long projectId;
//[...]
}
@Entity
@Table(name ="item")
public class Item {
private Integer id;
private String name;
private List<ProductItem> productItems = new LinkedList<ProductItem>();
public Item() {
}
@Entity
@Table(name ="product")
public class Product {
private Integer id;
private String name;
private List<ProductItem> productItems =new LinkedList<ProductItem>();
public Product() {
}
@Entity
@Table(name ="product_item")
@AssociationOverrides({
@AssociationOverride(name ="pk.item", joinColumns = @JoinColumn(name ="item_id")),
@AssociationOverride(name ="pk.product", joinColumns = @JoinColumn(name ="product_id"))
})
public class ProductItem {
private ProductItemPk pk =new ProductItemPk();
@Embeddable
public class ProductItemPk implements Serializable {
private Item item;
private Product product;
@ManyToOne
public Item getItem() {
return item;
}