dao

Java Generics. What benefit in my case?

*爱你&永不变心* 提交于 2019-12-11 06:45:39
问题 At this moment I start work on small web application based on MVC. Now I try implement main classes for Model layout using DAO pattern. So, first of all I create two entity classes (for example): Author and Book: package myProject.model.entity; import java.io.Serializable; public class Author implements Serializable { private static final long serialVersionUID = 7177014660621405534L; private long id; private String firstName; private String lastName; public Author() { } // getter and setter

Does the DAO pattern spoils cohesion /SRP?

孤者浪人 提交于 2019-12-11 05:38:41
问题 Let's use as example: class AccountDAO { create(){..} read(){..} update(){..} delete() {..} } How many responsibilities are there? 1 or 4? 回答1: SRP shouldn't be understood in a strict manner. One object should have very few responsibilities, not "one". Here AccountDAO is only responsible for Account persistence, so it has only one responsibility. 来源: https://stackoverflow.com/questions/6483392/does-the-dao-pattern-spoils-cohesion-srp

'Undefined function' when using DAO QueryDef in VBA

删除回忆录丶 提交于 2019-12-11 05:38:34
问题 I'm assigning an Access 2007 query to a QueryDef in Excel VBA. My query calls a user-defined function, because it performs a calculation on the results of evaluating a field with a regular expression. I'm using a QueryDef because I'm collecting values in a UserForm and want to pass them to the query as parameters. When I run my VBA code, I get an error: "Run-time error '3085': Undefined function 'regexFunc' in expression." This question suggests that the problem is that DAO is unable to call

DAO Design Pattern and Servlets

天大地大妈咪最大 提交于 2019-12-11 05:28:49
问题 I am reading about the DAO design pattern on Oracle's website and I'm trying to understand the below image in the context of using JSP's, Servlets, plain java objects, and the MVC pattern. In my case would the BusinessObject be my servlet and the TransferObject be my java class with only properties, mutators, and accessors (DTO)? For example, if I had this code in a servlet (controller) DTO.setFirstName(request.getParameter("firstName")); DTO.setLastName(request.getParameter("lastName")); DAO

OpenRecordset Method Issue With Too few Parameters

十年热恋 提交于 2019-12-11 00:01:55
问题 This seemingly simple problem has me stopped dead in my tracks for three days now. My code: Dim rs As DAO.Recordset Set rs = CurrentDb.OpenRecordset("qryAutoOrder", dbOpenDynaset) qryAutoOrder is a select query which runs just fine by itself and has no parameters (unless criteria in the query builder count). When the code runs it hangs on the set rs = line and throws this error. Run-time error '3061': Too few parameters. Expected 1. There is more to the code where I would like it to run a

MS Access Control Property.Type not making sense

一世执手 提交于 2019-12-10 21:27:38
问题 I have written code dealing with TableDef and Field properties in the past. It's not hard, it just involves looping through the Field.Properties collection and doing a certain amount of error checking along the way. Property.Name, Property.Type and Property.Value yield everything we need. The problem: I have just written some code to do the same kind of property enumeration for Form and Report controls. The property name and values come through fine, but the .Type is not correct. An example:

GWT RPC: DTO vs. DAO?

喜你入骨 提交于 2019-12-10 20:35:30
问题 I've started learning GWT about a week ago and here's the question I can't answer for sure. Here's the server-side: // business object - has logic interface Article { String getTitle(); // lazy void setTitle(); String getText(); // lazy void setText(); Set<Comment> getComments(); // lazy } // also has logic interface Comment { ... } I need to somehow create a GWT widget to visualize Article . Passing Article won't work, since it's not serializable and moreover, it has some BL. So, there are 2

抽取dao层,service层

允我心安 提交于 2019-12-10 20:14:27
一.后台支持(dao与service) 1.1 Dao层 1.1.1 创建BaseRepsitory接口 @NoRepositoryBean : 让Spring管理的时候不要为它创建实现 因为其下有多个子接口,创建实现类时,不知道具体创建哪个 /** * 公共的父Repository * @param <T> * @param <ID> */ @NoRepositoryBean public interface BaseRepository<T,ID extends Serializable> extends JpaRepository<T,ID>,JpaSpecificationExecutor<T> { } 1.1.2 EmployeeRepsitory 注意: 改成继承 BaseRepsitory 加入泛型类型 public interface EmployeeRepository extends BaseRepository<Employee,Long>{ ... } 1.2 Service层 1.2.1 IBaseService:父接口 定义一些方法 /** * Service的父接口(所有service都有CRUD) */ public interface IBaseService<T, ID extends Serializable> { //添加或者修改 void

JPA data access object - exception handling and rollback

北战南征 提交于 2019-12-10 19:49:48
问题 I'd like to know what the best way of exception handling in data access objects is, I'm interested in production quality code. As an example public UserDaoImpl implements UserDao{ @PersistenceContext private EntityManager em; void save(User user){ em.persist(user); } User getById(long id){ return em.find(User.class,id); } } Let's say that for example I have a RegisterService somewhere where at some point I'd like to save the user to the database. And that each User needs to have a unique

GreenDAO: Entity is detached from DAO context

隐身守侯 提交于 2019-12-10 17:47:25
问题 I use GreenDAO. But, throws this exception: "de.greenrobot.dao.DaoException: Entity is detached from DAO context". In the generated code, i find this code. /** called by internal mechanisms, do not call yourself. */ public void __setDaoSession(DaoSession daoSession) { this.daoSession = daoSession; myDao = daoSession != null ? daoSession.getPeerGroupDao() : null; } Anyone know when the GreenDAO call it? Also, how to trigger it to call. Thanks. 回答1: I find solution. The greenDAO call _