This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Embeddable | |
| public class ProductItemPk implements Serializable { | |
| private Item item; | |
| private Product product; | |
| @ManyToOne | |
| public Item getItem() { | |
| return item; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Entity | |
| @Table(name ="product") | |
| public class Product { | |
| private Integer id; | |
| private String name; | |
| private List<ProductItem> productItems =new LinkedList<ProductItem>(); | |
| public Product() { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Entity | |
| @Table(name ="item") | |
| public class Item { | |
| private Integer id; | |
| private String name; | |
| private List<ProductItem> productItems = new LinkedList<ProductItem>(); | |
| public Item() { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ProjectAssociationId { | |
| private long employeeId; | |
| private long projectId; | |
| //[...] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Entity | |
| public class Project { | |
| @Id | |
| private long id; | |
| ... | |
| @OneToMany | |
| private List<ProjectAssociation> employees; | |
| ... | |
| // Add an employee to the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Entity | |
| public class Employee { | |
| @Id | |
| private long id; | |
| ... | |
| @OneToMany | |
| private List<ProjectAssociation> projects; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HelloWorld { | |
| public static void main(String[] args) { | |
| System.out.println("Hello World!"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
NewerOlder