prima implementazione di persistence usando eclipselink e database integrato in glassfish.

This commit is contained in:
2015-05-04 01:27:46 +02:00
parent b76f6811dd
commit 5d21a01bcc
5 changed files with 161 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
package test3_persistence;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
/**
* Created by Giovanni on 04/05/2015.
*/
@Stateless
public class store_class {
@PersistenceContext(unitName = "test3")
private EntityManager em;
public void store_class(test_class t){
em.persist(t);
}
}

View File

@@ -0,0 +1,41 @@
package test3_persistence;
import javax.annotation.PostConstruct;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
@Entity
@NamedQuery(name = "findxg", query = "SELECT b FROM test_class b WHERE b.title ='xg'")
public class test_class {
@Id @GeneratedValue
private Long id;
@PostConstruct
public void ps (){
title = "xg";
}
private String title;
private Double price;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
}