1.1 --- a/pom.xml Fri Aug 12 16:34:36 2011 +0300
1.2 +++ b/pom.xml Tue Aug 16 09:09:18 2011 +0300
1.3 @@ -125,6 +125,11 @@
1.4 <version>1.0.0</version>
1.5 </dependency>
1.6 <dependency>
1.7 + <groupId>com.vaadin.addon</groupId>
1.8 + <artifactId>jpacontainer-addon-agpl-3.0</artifactId>
1.9 + <version>1.2.0</version>
1.10 + </dependency>
1.11 + <dependency>
1.12 <groupId>com.google.gwt</groupId>
1.13 <artifactId>gwt-dev</artifactId>
1.14 <version>${gwt.version}</version>
2.1 --- a/src/main/java/ru/indvdum/mywork/openjpa/model/DBObject.java Fri Aug 12 16:34:36 2011 +0300
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,12 +0,0 @@
2.4 -package ru.indvdum.mywork.openjpa.model;
2.5 -
2.6 -import java.io.Serializable;
2.7 -
2.8 -/**
2.9 - * @author indvdum
2.10 - * 12.08.2011 17:31:11
2.11 - *
2.12 - */
2.13 -public interface DBObject extends Serializable {
2.14 -
2.15 -}
3.1 --- a/src/main/java/ru/indvdum/mywork/openjpa/model/Day.java Fri Aug 12 16:34:36 2011 +0300
3.2 +++ b/src/main/java/ru/indvdum/mywork/openjpa/model/Day.java Tue Aug 16 09:09:18 2011 +0300
3.3 @@ -1,7 +1,12 @@
3.4 package ru.indvdum.mywork.openjpa.model;
3.5
3.6 +import java.sql.Time;
3.7 +import java.util.Date;
3.8 +
3.9 import javax.persistence.Column;
3.10 import javax.persistence.Entity;
3.11 +import javax.persistence.GeneratedValue;
3.12 +import javax.persistence.GenerationType;
3.13 import javax.persistence.Id;
3.14 import javax.persistence.Table;
3.15
3.16 @@ -12,14 +17,80 @@
3.17 */
3.18 @Entity
3.19 @Table(name = "DAYS")
3.20 -public class Day implements DBObject {
3.21 +public class Day implements IDatabaseObject {
3.22
3.23 - /**
3.24 - *
3.25 - */
3.26 private static final long serialVersionUID = 1471705339524132968L;
3.27
3.28 @Id
3.29 - @Column(name = "ID")
3.30 - private Integer id;
3.31 + @GeneratedValue(strategy = GenerationType.IDENTITY)
3.32 + @Column(name = "ID", nullable = false)
3.33 + private Integer id = null;
3.34 +
3.35 + @Column(name = "DAY")
3.36 + private Date day = null;
3.37 +
3.38 + @Column(name = "STARTWORK")
3.39 + private Time startWork = null;
3.40 +
3.41 + @Column(name = "ENDWORK")
3.42 + private Time endWork = null;
3.43 +
3.44 + @Column(name = "HOURS")
3.45 + private Float hours = null;
3.46 +
3.47 + public Day(){
3.48 +
3.49 + }
3.50 +
3.51 + @Override
3.52 + public boolean equals(Object obj) {
3.53 + if (this == obj)
3.54 + return true;
3.55 + if (obj == null)
3.56 + return false;
3.57 + if (!(obj instanceof Day))
3.58 + return false;
3.59 + final Day other = (Day) obj;
3.60 + return (this.id == other.id || (this.id != null && this.id.equals(other.id)));
3.61 + }
3.62 +
3.63 + public Integer getId() {
3.64 + return id;
3.65 + }
3.66 +
3.67 + public void setId(Integer id) {
3.68 + this.id = id;
3.69 + }
3.70 +
3.71 + public Date getDay() {
3.72 + return day;
3.73 + }
3.74 +
3.75 + public void setDay(Date day) {
3.76 + this.day = day;
3.77 + }
3.78 +
3.79 + public Time getStartWork() {
3.80 + return startWork;
3.81 + }
3.82 +
3.83 + public void setStartWork(Time startWork) {
3.84 + this.startWork = startWork;
3.85 + }
3.86 +
3.87 + public Time getEndWork() {
3.88 + return endWork;
3.89 + }
3.90 +
3.91 + public void setEndWork(Time endWork) {
3.92 + this.endWork = endWork;
3.93 + }
3.94 +
3.95 + public Float getHours() {
3.96 + return hours;
3.97 + }
3.98 +
3.99 + public void setHours(Float hours) {
3.100 + this.hours = hours;
3.101 + }
3.102 }
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/src/main/java/ru/indvdum/mywork/openjpa/model/IDatabaseObject.java Tue Aug 16 09:09:18 2011 +0300
4.3 @@ -0,0 +1,12 @@
4.4 +package ru.indvdum.mywork.openjpa.model;
4.5 +
4.6 +import java.io.Serializable;
4.7 +
4.8 +/**
4.9 + * @author indvdum
4.10 + * 12.08.2011 17:31:11
4.11 + *
4.12 + */
4.13 +public interface IDatabaseObject extends Serializable {
4.14 +
4.15 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/src/main/java/ru/indvdum/mywork/openjpa/model/Task.java Tue Aug 16 09:09:18 2011 +0300
5.3 @@ -0,0 +1,59 @@
5.4 +package ru.indvdum.mywork.openjpa.model;
5.5 +
5.6 +import javax.persistence.Column;
5.7 +import javax.persistence.Entity;
5.8 +import javax.persistence.GeneratedValue;
5.9 +import javax.persistence.GenerationType;
5.10 +import javax.persistence.Id;
5.11 +import javax.persistence.Table;
5.12 +
5.13 +/**
5.14 + * @author indvdum
5.15 + * 16.08.2011 9:02:32
5.16 + *
5.17 + */
5.18 +@Entity
5.19 +@Table(name = "TASKS")
5.20 +public class Task implements IDatabaseObject {
5.21 +
5.22 + private static final long serialVersionUID = -4457948503094306717L;
5.23 +
5.24 + @Id
5.25 + @GeneratedValue(strategy = GenerationType.IDENTITY)
5.26 + @Column(name = "ID", nullable = false)
5.27 + private Integer id = null;
5.28 +
5.29 + @Column(name = "NAME")
5.30 + private String name = null;
5.31 +
5.32 + @Column(name = "DESCRIPTION")
5.33 + private String description = null;
5.34 +
5.35 + public Task(){
5.36 +
5.37 + }
5.38 +
5.39 + public Integer getId() {
5.40 + return id;
5.41 + }
5.42 +
5.43 + public void setId(Integer id) {
5.44 + this.id = id;
5.45 + }
5.46 +
5.47 + public String getName() {
5.48 + return name;
5.49 + }
5.50 +
5.51 + public void setName(String name) {
5.52 + this.name = name;
5.53 + }
5.54 +
5.55 + public String getDescription() {
5.56 + return description;
5.57 + }
5.58 +
5.59 + public void setDescription(String description) {
5.60 + this.description = description;
5.61 + }
5.62 +}
6.1 --- a/src/main/java/ru/indvdum/mywork/vaadin/MyWorkApplication.java Fri Aug 12 16:34:36 2011 +0300
6.2 +++ b/src/main/java/ru/indvdum/mywork/vaadin/MyWorkApplication.java Tue Aug 16 09:09:18 2011 +0300
6.3 @@ -9,6 +9,10 @@
6.4 import ru.indvdum.mywork.openjpa.model.Day;
6.5
6.6 import com.vaadin.Application;
6.7 +import com.vaadin.addon.jpacontainer.JPAContainer;
6.8 +import com.vaadin.addon.jpacontainer.provider.LocalEntityProvider;
6.9 +import com.vaadin.ui.Table;
6.10 +import com.vaadin.ui.VerticalLayout;
6.11 import com.vaadin.ui.Window;
6.12
6.13 /**
6.14 @@ -22,8 +26,22 @@
6.15 public void init() {
6.16 Window window = new Window();
6.17 setMainWindow(window);
6.18 +
6.19 + VerticalLayout vl = new VerticalLayout();
6.20 + window.setContent(vl);
6.21 +
6.22 Query query = EM.createQuery("select x from " + Day.class.getName() + " x");
6.23 List list = query.getResultList();
6.24 list.size();
6.25 +
6.26 +// LocalEntityProvider entityProvider = new LocalEntityProvider(Day.class);
6.27 +// entityProvider.setEntityManager(EM);
6.28 +// JPAContainer<Day> dayContainer = new JPAContainer(Day.class);
6.29 +// dayContainer.setEntityProvider(entityProvider);
6.30 +//
6.31 +// Table dayTable = new Table();
6.32 +// dayTable.setSizeFull();
6.33 +// dayTable.setContainerDataSource(dayContainer);
6.34 +// vl.addComponent(dayTable);
6.35 }
6.36 }