本文整理汇总了Java中javax.persistence.EntityManager.createNamedQuery方法的典型用法代码示例。如果您正苦于以下问题:Java EntityManager.createNamedQuery方法的具体用法?Java EntityManager.createNamedQuery怎么用?Java EntityManager.createNamedQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.persistence.EntityManager
的用法示例。
在下文中一共展示了EntityManager.createNamedQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readRow
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public String readRow(String name) {
EntityManager em=emf.createEntityManager();
Query q=em.createNamedQuery("Preferences.findByName");
q.setParameter("name", name);
List<Preferences> l=q.getResultList();
if(l.size()==0) return null;
Preferences p=l.get(0);
em.close();
return p.getValue();
}
示例2: PreferencesDialog
import javax.persistence.EntityManager; //导入方法依赖的package包/类
/** Creates new form PreferencesDialog */
public PreferencesDialog() {
initComponents();
emf = Persistence.createEntityManagerFactory("GeoImageViewerPU");
EntityManager em = emf.createEntityManager();
Query q = em.createNamedQuery("Preferences.findAll");
prefs = q.getResultList();
em.close();
setTitle("SUMO Preferences");
initTable();
}
示例3: loadAll
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void loadAll() {
List<DocumentDetail> ListDocumentDetail = new ArrayList<DocumentDetail>();
Items it = new Items();
EntityManager em = it.getEntityManager();
TypedQuery<DocumentDetail> consultItems = em.createNamedQuery("DocumentDetail.findAll", DocumentDetail.class);
ListDocumentDetail = consultItems.getResultList();
ListProducts = new ArrayList<Products>();
for (DocumentDetail selectedItem : ListDocumentDetail) {
Products newProduct = new Products();
newProduct.setArticulo(selectedItem.getItemId().getName());
newProduct.setBodega(selectedItem.getWarehousesId().getName());
if (selectedItem.getDocumentId().getTypedocId().getCode().equals("1")) {
newProduct.setEntradas(selectedItem.getQuantity());
} else {
newProduct.setSallidas(selectedItem.getQuantity());
}
newProduct.setFecha(selectedItem.getDocumentId().getDocumentDate().toString());
newProduct.setConsecutivo(selectedItem.getDocumentId().getConsecutive() + "");
ListProducts.add(newProduct);
}
}
示例4: loadMore
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void loadMore() {
List<DocumentDetail> ListDocumentDetail = new ArrayList<DocumentDetail>();
Items it = new Items();
EntityManager em = it.getEntityManager();
TypedQuery<DocumentDetail> consultItems = em.createNamedQuery("DocumentDetail.findAll", DocumentDetail.class);
ListDocumentDetail = consultItems.getResultList();
ListProducts = new ArrayList<Products>();
ListMoreProducts = new ArrayList<Products>();
for (DocumentDetail selectedItem : ListDocumentDetail) {
Products newProduct = new Products();
newProduct.setArticulo(selectedItem.getItemId().getName());
Products alreadyItem = findInListMoreProducts(newProduct.getArticulo());
if (alreadyItem == null) {
if (selectedItem.getDocumentId().getTypedocId().getCode().equals("1")) {
newProduct.setEntradas(selectedItem.getQuantity());
} else {
newProduct.setSallidas(selectedItem.getQuantity());
}
ListMoreProducts.add(newProduct);
} else {
if (selectedItem.getDocumentId().getTypedocId().getCode().equals("1")) {
alreadyItem.setEntradas((alreadyItem.getEntradas() != null ? alreadyItem.getEntradas() : 0) + selectedItem.getQuantity());
} else {
alreadyItem.setSallidas((alreadyItem.getSallidas() != null ? alreadyItem.getSallidas() : 0) + selectedItem.getQuantity());
}
}
}
SumMoreProducts();
}
示例5: searchProduct
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void searchProduct(){
EntityManager em = i.getEntityManager();
TypedQuery<Items> consultarProducto = em.createNamedQuery("Items.findByCode",Items.class);
consultarProducto.setParameter("code",i.getCode());
List<Items> productos = consultarProducto.getResultList();
if(productos.size()>0){
i = productos.get(0);
}else{
i = new Items();
}
}
示例6: searchDocument
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void searchDocument(){
EntityManager em = d.getEntityManager();
TypedQuery<Document> consultDocument = em.createNamedQuery("Document.findByConsecutive",Document.class);
consultDocument.setParameter("consecutive",d.getConsecutive());
List<Document> document = consultDocument.getResultList();
if(document.size()>0){
d = document.get(0);
alldd = new ArrayList<DocumentDetail2>();
total = 0;
em = dd.getEntityManager();
TypedQuery<DocumentDetail> consultDocumentD = em.createNamedQuery("DocumentDetail.findByDocument",DocumentDetail.class);
consultDocumentD.setParameter("documentId",d);
List<DocumentDetail> documentD = consultDocumentD.getResultList();
for(int i = 0; i < documentD.size();i++){
DocumentDetail2 dd2 = new DocumentDetail2();
dd2.setDd(documentD.get(i));
dd2.setDocumentDetailId(i);
dd2.setTempi(documentD.get(i).getItemId().getItemId());
dd2.setTempw(documentD.get(i).getWarehousesId().getWarehousesId());
alldd.add(dd2);
total += dd2.getDd().getPrice();
}
temptd = d.getTypedocId().getTypedocId();
visualTotal = new BigDecimal(total)+"";
disabled = true;
consecutive = false;
visibilityCreate = "none";
visibilityUpdate = "none";
visibilityEdit = "inline";
}else{
searchD();
}
}
示例7: listTypeDoc
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void listTypeDoc(){
EntityManager em = td.getEntityManager();
//Query tipado con el tipo de objeto a extraer
TypedQuery<TypeDoc> consulusert = em.createNamedQuery("TypeDoc.findAll",TypeDoc.class);
//captura de listado de la consulta
alltd = consulusert.getResultList();
}
示例8: listWarehouse
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void listWarehouse(){
EntityManager em = w.getEntityManager();
//Query tipado con el tipo de objeto a extraer
TypedQuery<Warehouses> consulusert = em.createNamedQuery("Warehouses.findAll",Warehouses.class);
//captura de listado de la consulta
allw = consulusert.getResultList();
}
示例9: listItems
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void listItems(){
EntityManager em = i.getEntityManager();
//Query tipado con el tipo de objeto a extraer
TypedQuery<Items> consuli= em.createNamedQuery("Items.findByIsActived",Items.class);
//captura de listado de la consulta
consuli.setParameter("isActived", true);
alli = consuli.getResultList();
}
示例10: listUserType
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void listUserType(){
EntityManager em = ut.getEntityManager();
//Query tipado con el tipo de objeto a extraer
TypedQuery<UsersType> consulusert = em.createNamedQuery("UsersType.findAll",UsersType.class);
//captura de listado de la consulta
allut = consulusert.getResultList();
}
示例11: listUsers
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void listUsers(){
EntityManager em = u.getEntityManager();
//Query tipado con el tipo de objeto a extraer
TypedQuery<Users> consuluser = em.createNamedQuery("Users.findAll",Users.class);
//captura de listado de la consulta
allu = consuluser.getResultList();
}
示例12: searchWarehouse
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void searchWarehouse(){
EntityManager em = w.getEntityManager();
TypedQuery<Warehouses> consultwarehouse = em.createNamedQuery("Warehouses.findByCode",Warehouses.class);
consultwarehouse.setParameter("code",w.getCode());
List<Warehouses> warehouse = consultwarehouse.getResultList();
if(warehouse.size()>0){
w = warehouse.get(0);
}else{
w = new Warehouses();
}
}
示例13: SalesSimulator
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public SalesSimulator(EntityManager em){
this.em = em;
// regionByZipCode = em.createNamedQuery("Region.findByZipCodePrefix", Region.class);
thisRandom = new Random();
Query q = em.createNamedQuery("ZipCityInfo.findAll", ZipCityInfo.class);
listOfZips = q.getResultList();
usRegions= new ArrayList<Region>();
intlRegions= new ArrayList<Region>();
generateRegionLists();
}
示例14: readFullProductListing
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public static void readFullProductListing(EntityManager entityManager){
Query namedQuery = entityManager.createNamedQuery("FullProductListing.findAll");
List products = namedQuery.getResultList();
System.out.println(products.size());
}
示例15: ConsecutiveDocument
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void ConsecutiveDocument(){
EntityManager em = d.getEntityManager();
TypedQuery<Document> consultDocument = em.createNamedQuery("Document.findAll",Document.class);
alld = consultDocument.getResultList();
d.setConsecutive(alld.size()+1);
}