- 浏览: 643235 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
HkEndless:
不好意思,请问这确定是回调机制吗。你的例子中只是将接口的实现类 ...
Spring CallBack回调机制介绍 -
hanmiao:
写的真乱啊,完全不知所云...
Java如何调用可执行文件和批处理命令 -
junia_1:
junia_1 写道 shock: ...
为什么要使用EJB -
junia_1:
shock:
为什么要使用EJB -
coollifer:
不错
SQL Server数据导入到Oracle中的方法
///////////////////////////////////////////////////////////////////////// import java.util.*; import java.sql.*; import org.hibernate.*; import org.hibernate.criterion.*; public class Main { public static void main(String[] args) { HibernateUtil.setup("create table Supplier ( id int, name VARCHAR);"); HibernateUtil.setup("create table Product ( id int, name VARCHAR, description VARCHAR, price double,supplierId int);"); prepareData(); Session session = HibernateUtil.currentSession(); Criteria crit = session.createCriteria(Product.class); crit.add(Restrictions.gt("price",new Double(1.0))); crit.addOrder(Order.desc("price")); List results = crit.list(); displayProductsList(results); HibernateUtil.checkData("select * from Supplier"); HibernateUtil.checkData("select * from Product"); } public static void displayProductsList(List list){ Iterator iter = list.iterator(); if (!iter.hasNext()){ System.out.println("No products to display."); return; } while (iter.hasNext()){ Product product = (Product) iter.next(); String msg = product.getSupplier().getName() + "\t"; msg += product.getName() + "\t"; msg += product.getPrice() + "\t"; msg += product.getDescription(); System.out.println(msg); } } private static void prepareData(){ Session session = HibernateUtil.currentSession(); Supplier supplier1 = new Supplier(); supplier1.setName("Supplier Name 1"); session.save(supplier1); Supplier supplier2 = new Supplier(); supplier2.setName("Supplier Name 2"); session.save(supplier2); Product product1 = new Product("Product 1","Name for Product 1", 2.0); product1.setSupplier(supplier1); supplier1.getProducts().add(product1); session.save(product1); Product product12 = new Product("Product 2","Name for Product 2", 22.0); product12.setSupplier(supplier1); supplier1.getProducts().add(product12); session.save(product12); Product product2 = new Product("Product 3", "Name for Product 3", 30.0); product2.setSupplier(supplier2); supplier2.getProducts().add(product2); session.save(product2); session.flush(); HibernateUtil.closeSession(); } } ///////////////////////////////////////////////////////////////////////// public class Product { private int id; private Supplier supplier; private String name; private String description; private double price; public Product() { super(); } public Product(String name, String description, double price) { super(); this.name = name; this.description = description; this.price = price; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Supplier getSupplier() { return supplier; } public void setSupplier(Supplier supplier) { this.supplier = supplier; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } } ///////////////////////////////////////////////////////////////////////// <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="Supplier"> <id name="id" type="int"> <generator class="increment"/> </id> <property name="name" type="string"/> <bag name="products" inverse="true" cascade="all,delete-orphan"> <key column="supplierId"/> <one-to-many class="Product"/> </bag> </class> </hibernate-mapping> ///////////////////////////////////////////////////////////////////////// import java.util.ArrayList; import java.util.List; public class Supplier { private int id; private String name; private List products = new ArrayList(); public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public List getProducts() { return products; } public void setProducts(List products) { this.products = products; } } /////////////////////////////////////////////////////////////////////////
发表评论
-
hibernate Restrictions用法 MatchMode.ANYWHERE
2012-07-14 15:50 3870方法 说明 Res ... -
hibernate3 大批量更新/删除数据 (update/delete)
2011-11-10 12:15 1342Hibernate3.0 采用新的基 ... -
hibernate lazy(延迟加载)
2011-10-12 02:20 885hibernate lazy策略可以使用在: * < ... -
一些关于Hibernate延迟加载的误区
2011-09-12 23:13 845首先是第一个误区:延迟加载只能作用于关联实体 看到这个是 ... -
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling
2011-08-12 19:17 1210Hi I am facing a problem wit ... -
Criteria Condition: Match Mode End
2011-07-02 11:05 947//////////////////////////// ... -
Criteria: Group By Criteria
2011-07-02 11:03 1254/////////////////////////////// ... -
Query Criteria Equal
2011-07-02 11:02 855/////////////////////////////// ... -
Criteria: Associations Sorting Criteria
2011-07-02 10:57 865//////////////////////////// ... -
hibernate的Query有没有setResultTransformer这个方法
2011-07-01 23:24 3044可以对原生SQL 查询使用ResultTransformer。 ... -
Hibernate中一级缓存、二级缓存及查询缓存的技术性总结
2011-06-21 17:31 1211一、 一级缓存 1. ... -
hibernate 保存 oracle 10g大数据字段
2011-06-14 04:01 1415Java代码 要点如下: ... -
Hibernate 错误原因总结
2011-06-14 00:10 13841、错误: object references an unsa ... -
MappingException提示Association references unmapped class错误的解决方法
2011-06-12 17:09 10出现如下错误信息时 Caused by: org.hibe ... -
Hibernate一对多关联映射的配置及其级联删除问题
2011-06-12 17:07 9首先举一个简单的一对多双向关联的配置: 一的一端:Quest ... -
Hibernate多对一关联映射原理、映射方法和数据的保存
2011-06-12 17:06 13Hibernate的多对一关联映射实现的基本原理就是: 在多 ... -
Hibernate一对多单向关联和双向关联映射方法及其优缺点
2011-06-12 17:05 11一对多关联映射和多对一关联映射实现的基本原理都是一样的,既是在 ... -
inverse = “true” example and explanation
2011-06-11 22:18 1087In Hibernate, only the “relatio ... -
ibatis和hibernate区别
2011-04-13 17:34 793ibatis:sql需要自己写 hibe ... -
Hibernate StackOverFlowError 异常出现的原因
2011-04-13 16:51 1242引起StackOverFlowError异常的一般是因为在程序 ...
相关推荐
Hibernate的Criteria用法总结Hibernate的Criteria用法总结
24.3. Customer(客户)/Order(订单)/Product(产品) 24.4. 杂例 24.4.1. "Typed" one-to-one association 24.4.2. Composite key example 24.4.3. Content based discrimination 24.4.4. Associations on ...
javax.persistence.criteria.Order.class javax.persistence.criteria.ParameterExpression.class javax.persistence.criteria.Path.class javax.persistence.criteria.PluralJoin.class javax.persistence.criteria...
Improved delay-dependent consensus stability criteria of high-order multi-agent systems with time delays
org.hibernate.criterion A framework for defining restriction criteria and order criteria. org.hibernate.mapping This package defines the Hibernate configuration-time metamodel. org.hibernate....
org.hibernate.criterion A framework for defining restriction criteria and order criteria. org.hibernate.mapping This package defines the Hibernate configuration-time metamodel. org.hibernate....
In order to improve the ability of resisting disturbance for memristive neural networks (MNNs), a general impulsive controlled MNN with variable delays is constructed in this paper. Then, its ...
The criteria used here based on the order date and the order status. When this criteria is satisfied certain elements are removed from the collection. This results in a sparse collection which is ...
具有通信时延的多个体系统的协调控制,刘成林,田玉平,本文考察了个体动态为二阶积分模型,具有通信时延的多个体系统的协调控制。基于频域分析方法与矩阵论,分别得到了系统渐进收敛静
$criteria->order='id DESC'; $count=User::model()->count($criteria); $pager=new CPagination($count); $pager->pageSize=10; $pager->applyLimit($criteria); $userList=User::model()->findAll
众所周知 modelName::model() -> find() //找出的是一个对象 modelName::model() -> findALL...$criteria->order = 'id DESC'; $users = modelName::model()->findAll( $criteria ); 后台无意中看到别人有这么写的,
Introducing Linux Distros teaches you the pros and the cons of the most frequently used distros in order to find the one that is right for you. You will explore each distro step by step, so that you ...
The order Application 357 The roster Application 369 The address-book Application 376 Chapter 21: The Java Persistence Query Language 381 Query Language Terminology 382 Creating Queries Using ...
Criteria 1.hibernate提供的更面向对象的一种查询方式。 准备工作: 1.java中的POJO对象存在 2.数据库,表得存在 3.hibernate的配置文件(hibernate.cfg.xml)得存在 4.POJO.hbm.xml文件存在 5.hibernate的jar包以及...
' ROW_NUMBER() OVER (ORDER BY RANK DESC) AS SerialNumber ,'+ ' F.[rank], '+ ' p.*' + ' FROM'+ ' FREETEXTTABLE( CapitalInfoFactTab , (ProvinceName, CityName, CountyName, Keyword,Title ,IndustryBName ...
下面我总结了在Yii常用的一些yii分页方式与实例代码,这里有普通分页与ajax实现分页,希望此文章对大家... //$criteria->order = ‘news_id DESC’; $criteria->condition = ‘user_id = 1’; $dataProvider
- Several criteria (AIC, BIC, FPE, MDL, SBC, CAT, PHI) for model order selection an autoregressive model are included. - Fast algorithms are used - missing values (encoded as NaN's) are considered
Automated Trading with R provides automated traders with all the tools they need to trade algorithmically with their existing brokerage, from data management, to strategy optimization, to order ...
- see all recipes, filter and order them by different criteria. - search recipe by name - see recipe's detail information. - like/dislike recipes - write comments to recipe - add new recipes - update ...
修正Criteria方式先使用queryCount再queryList,order by丢失问题 修正RunBinder拦截器事务嵌套有错时,事务回滚出错问题 配置动态数据源请看这里: 数据水平分表请看这里: ##核心组件dexcoder-dal使用说明 dexcoder-...