prima implementazione di persistence usando eclipselink e database integrato in glassfish.
This commit is contained in:
28
test3_persistence/store_class.java
Normal file
28
test3_persistence/store_class.java
Normal 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
41
test3_persistence/test_class.java
Normal file
41
test3_persistence/test_class.java
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user