dao

DAO vs ORM(hibernate) pattern [closed]

一笑奈何 提交于 2019-12-04 07:20:01
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . i read in some articles DAO is not mandatory with hibernate and its implementation is by "it depends", in other words, we can choose between ORM vs DAO pattern. Ok, let's assume that i don't want use a DAO pattern, so im using only session CRUD and query operation provided by

Set Recordset Type of QueryDef via VBA

主宰稳场 提交于 2019-12-04 05:40:21
问题 I can set the Recordset Type of a select query in Access (2002) by opening the query in design view, opening its property sheet, and changing the Recordset Type property to one of three values: Dynaset Dynaset (Inconsistent Updates) Snapshot I can't figure out how to set the property through VBA, though. Am I missing something obvious? 回答1: I am not sure about this: Dim qdf As QueryDef Set qdf = CurrentDb.CreateQueryDef("test", "select * from atable") qdf.Properties.Append qdf.CreateProperty(

Java Generic of Another generic

若如初见. 提交于 2019-12-04 05:20:57
I have interface: interface Identifable<T extends Serializable> { T getID(); } and class that implement this: public class Cat implements Identifable<Long> { public Long getID(){...}; } everything works fine. so far. Now I want to create GenericDAO, why I cannot create this?: public abstract GenericDAO<T extends Identifable<S>> { T getByID(S id); } I can only declare my GenericDAO as this: public abstract GenericDAO<T extends Identifable, S> { T getById(S id); } And complete class: public CatDAO extends GenericDAO<Cat, Long> { Cat getById(Long id); } But i think it's useless, because I repeat

Is it OK to have singleton DAO objects?

若如初见. 提交于 2019-12-04 03:07:19
问题 Consider the following classes' structure: BaseDAO with methods to crest PreparedStatement and get connection from pool AccountDAO extends BaseDAO to work with Account table via JDBC. This class is singleton AccountService witch calls methods of AccountDAO like this: AccountDAO.getInstance().login(name, password). AccountDAO is a Spring bean with @Transactional annotations to methods that insert some data. Is this OK? I think singleton DAO classes can cause performance problems. May be it is

PO BO VO DTO POJO DAO 概念及其作用

让人想犯罪 __ 提交于 2019-12-04 00:06:27
PO(bean,entity等命名) : persistant object持久对象,数据库表中的记录在java对象中的显示状态 最形象的理解就是一个PO就是数据库中的一条记录。 好处是可以把一条记录作为一个对象处理,可以方便的转为其它对象。 BO(service,manager,business等命名): business object 业务对象 主要作用是把业务逻辑封装为一个对象。这个对象可以包括一个或多个其它的对象。 形象描述为一个对象的形为和动作,当然也有涉及到基它对象的一些形为和动作。比如处理 一个人的业务逻辑,有睡觉,吃饭,工作,上班等等形为还有可能和别人发关系的形为。 这样处理业务逻辑时,我们就可以针对BO去处理。 VO(from也有此写法) : value object值对象 主要体现在视图的对象, 对于一个WEB页面 将整个页面的属性封装成一个对象。然后 用一个VO对象 在控制层与视图层进行传输交换。 DTO (经过处理后的PO,可能增加或者减少PO的属性): Data Transfer Object数据传输对象 主要用于远程调用等需要大量传输对象的地方。 比如我们一张表有100个字段,那么对应的PO就有100个属性。 但是我们界面上只要显示10个字段, 客户端用WEB service来获取数据,没有必要把整个PO对象传递到客户端,

spring - how to autowire data source?

孤人 提交于 2019-12-03 21:02:54
I'm having some problem with autowire and DI in general, so I hope that someone can help cause I've been stuck for days now. This is the code: @Service public class TicketsController implements Controller { private TicketManager ticketManager; @Autowired public void setTicketManager(TicketManager ticketManager) { this.ticketManager = ticketManager; } ... } @Service public class SimpleTicketManager implements TicketManager { private TicketsDao ticketsDao; @Autowired public void setTicketsDao(TicketsDao ticketsDao) { this.ticketsDao = ticketsDao; } ... } @Repository public class JdbcTicketDao

设计模式-抽象工厂模式

主宰稳场 提交于 2019-12-03 20:47:07
模式动机 在工厂方法模式中具体工厂负责生产具体的产品,每一个具体工厂对应一种具体产品,工厂方法也具有唯一性,一般情况下,一个具体工厂只有一个工厂方法或者一组重载的工厂方法。但是有时候我们需要一个工厂可以提供多个产品对象,而不是单一的产品对象。 为了更清晰的理解工厂方法模式,需要先引入两个概念: 产品等级结构:产品等级结构即产品的继承结构,如一个抽象类是电视机,其子类有海尔电视机、海信电视机、TCL电视机,则抽象电视机与具体品牌的电视机之间构成了一个产品等级结构,抽象电视机是父类,而具体品牌的电视机是其子类。 产品族:在抽象工厂模式中,产品族是指由同一个工厂生产的,位于不同产品等级结构中的一组产品,如海尔电器工厂生产的海尔电视机、海尔电冰箱,海尔电视机位于电视机产品等级结构中,海尔电冰箱位于电冰箱产品等级结构中。 当系统所提供的工厂所需生产的具体产品并不是一个简单的对象,而是多个位于不同产品等级结构中属于不同类型的具体产品时需要使用抽象工厂模式。 抽象工厂模式是所有形式的工厂模式中最为抽象和最具一般性的一种形态 抽象工厂模式与工厂模式最大的区别在于,工厂方法模式针对的是一个产品等级结构,而抽象工厂模式则需要面对多个产品等级结构,一个工厂等级结构可以负责多个不同产品等级结构中的产品对象的创建。当一个工厂等级结构可以创建出分属于不同产品等级结构的一个产品族中的所有对象时

What is the necessity of DAO Architecture

こ雲淡風輕ζ 提交于 2019-12-03 19:37:37
When programming in Java is it always necessary to code according to the DAO architecture? If so what are advantages of using it? I'm doing a project which has a class diagram like below. what are the disadvantages of this? Entity Class: private void fillSONumber() { try { ZnAlSalesOrder o = new ZnAlSalesOrder(); ArrayList a = o.getPendingSalesOrderIDs(); for (int i = 0; i < a.size(); i++) { cmbSoNo.addItem(a.get(i)); } o.close(); } catch (Terminated ex) { } } EntityTable Class Example: public ResultSet select(String fields, String selection) { db = new Database(); db.select("SELECT " + fields

Room “Not sure how to convert a Cursor to this method's return type”: which method?

无人久伴 提交于 2019-12-03 19:17:15
问题 Error:Not sure how to convert a Cursor to this method's return type Error:Execution failed for task ':app:compileDebugJavaWithJavac'. Compilation failed; see the compiler error output for details. Using Room I'm getting this error and I'd like to find out which method causes it. I have multiple DAO s, with approximately 60 methods in total, and this error just popped up after adding a method (copy&pasted from another one that worked perfectly, just changed the field to set). I could post the

Strategy for many DAOs in Spring Java

断了今生、忘了曾经 提交于 2019-12-03 14:42:39
We have many DAOs in an existing project (currently with no interfaces, but that can change). Rather than wiring a Spring-managed bean for each DAO class and injecting them into the service layer, we have a DAO "factory" of sorts that looks like this: public class DAOFactory { private static DAOFactory daoFac; static{ daoFac = new DAOFactory(); } private DAOFactory(){} public static DAOFactory getInstance(){ return daoFac; } public MyDAO1 getMyDAO1(){ return new MyDAO1(); } public MyDAO2 getMyDAO2(){ return new MyDAO2(); } ... (Note that MyDAO1 and MyDAO2 are concrete classes) This allows us