Position: Home page » Ethereum » Ethereum daosupport

Ethereum daosupport

Publish: 2021-04-22 04:24:32
1. Is the data access object. Because your data is saved to the database, and there are so many databases, their implementation is different, so that the design can have different implementation for different databases. It's easy to expand in the future.
2. There are many methods. You can use hibernate to help you encapsulate them. You can also use JDBC, the simplest and most crude method, connectioncon = session. Connection(); Here you get Conn, and then you will use JDBC. Of course, you need to get session first. In Hibernate, I think it's not difficult to get session
3. Hibernatesupport class is a tool class provided by spring for hibernate Dao. This class mainly provides the following two methods to facilitate the implementation of Dao:
1. Public final hibernatetemplate gethibernatetemplate()
2. Public final void setsessionfactory (sessionfactory sessionfactory)
the setsessionfactory method is used to receive the dependency injection of spring's ApplicationContext, and can receive the sessionfactory instance configured in spring, The gethibernatetemplate method is used to generate a session according to the previous sessionfactory, and finally generate a hibernatetemplate to complete the database access.
4. 参考下我的代码吧 后面加上order by sfmc就可以了
首先要把多条件放到一个数组中
再调用hibernateDAOSupport中的方法
public Critique fingCritique(int AId, Date date) {
Object values[] = new Object[]{AId,date};
List critiqueFind = this.getHibernateTemplate().find("select cri from Critique cri where cri.AId = ? AND cri.date = ?", values);
if(!critiqueFind.isEmpty()){
return (Critique)critiqueFind.get(0);
}else{
return null;
}
}
5. The difference is this: entitymanager is used to annotate the entity class jpalsupport across databases. Hibernatesupport does not praise databases!! The advantages and disadvantages can be known according to the understanding
6. 1、/**
* 删除记录
* @param entity BO的对象
* <pre>
* this.getHibernateTemplate().delete(entity);
* 按照规范,调用ECLRecordDelete记录删除的BO信息;
* </pre>
*/
public void delete(Object entity){
this.getHibernateTemplate().delete(entity);
}
2、 /**
* 通过id获得记录
* @param Class entityClass,对象类型
* @param Serializable id,BO的id值
* <pre>
* return hibernateTemplate.get(entityClass,id);
* </pre>
*/
public Object findById(Class entityClass, Serializable id) {
return this.getHibernateTemplate().get(entityClass,id);
}

3、/**
* 获得延迟加载数据
* @param Object object,需要加载的对象
* <pre>
* Hibernate.initialize(object);
* </pre>
*/
public void getLazyData(Object object) {
this.getHibernateTemplate().initialize(object);
}
7. 因为如果使用继承关系的话,耦合度比较高,也就是说不够优化,并且没办法是先spring的注入,所以现在一般用的比较少

层现在一般都是通过hql语言,更方便一些
举例:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List result=session.createQuery("from Classes as a where a.classno
like " '%"+OId+"%'").list();
[sql] view plainprint?
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List result=session.createQuery("from Classes as a where a.classno like " '%"+OId+"%'").list();
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List result=session.createQuery("from Classes as a where a.classno like " '%"+OId+"%'").list();
8. You need to import spring-orm.jar
Hot content
Inn digger Publish: 2021-05-29 20:04:36 Views: 341
Purchase of virtual currency in trust contract dispute Publish: 2021-05-29 20:04:33 Views: 942
Blockchain trust machine Publish: 2021-05-29 20:04:26 Views: 720
Brief introduction of ant mine Publish: 2021-05-29 20:04:25 Views: 848
Will digital currency open in November Publish: 2021-05-29 19:56:16 Views: 861
Global digital currency asset exchange Publish: 2021-05-29 19:54:29 Views: 603
Mining chip machine S11 Publish: 2021-05-29 19:54:26 Views: 945
Ethereum algorithm Sha3 Publish: 2021-05-29 19:52:40 Views: 643
Talking about blockchain is not reliable Publish: 2021-05-29 19:52:26 Views: 754
Mining machine node query Publish: 2021-05-29 19:36:37 Views: 750