dao

Access: Get newly created auto number in DAO

家住魔仙堡 提交于 2019-12-10 17:10:07
问题 I have a code in DAO that connects to a linked table in SQL Server 2008. I need to get the newly created auto number on .AddNew . Set db = CurrentDb Set rs = db.OpenRecordset("AuditTrail") rs.AddNew rs("ActionID") = actionAdd rs("dtDateTime") = Now() rs("FormName") = frmName rs("TableName") = tblName rs("RecordID") = actionAdd rs("Comment") = Nz(comment, "") rs("UserID") = UserIDName rs("UsernamePC") = VBA.Environ("USERDOMAIN") rs("DomainPC") = VBA.Environ("USERDOMAIN") rs("ComputerNamePC") =

Spring integration test does not roll back

こ雲淡風輕ζ 提交于 2019-12-10 14:16:54
问题 I'm using Spring + Hibernate + H2. I do database operations in my integration tests (by calling a service class). I want Spring to rollback the changes after each test method, but I can't get it to work. At first I used MySQL (with MyISAM, which doesn't support transaction), but after changing to H2 the problem remains. I tried several DataSource-definitions (after reading that it must be XA-aware), but nothing seems to help. I use http://code.google.com/p/generic-dao/ for my DAO-classes and

Optional query parameters for Android Room

落花浮王杯 提交于 2019-12-10 10:56:24
问题 I have the following DAO with a query: @Dao public interface BaseballCardDao { @Query( "SELECT * FROM baseball_cards " + "WHERE brand LIKE :brand " + " AND year = :year " + " AND number LIKE :number " + " AND player_name LIKE :playerName " + " AND team LIKE :team" ) LiveData<List<BaseballCard>> getBaseballCards( String brand, int year, String number, String playerName, String team ); } The String parameters are "optional" in the sense that I can pass "%%" to match all rows due to the LIKE

ORMLite ForeignCollection: Must use ClosableIterator?

我只是一个虾纸丫 提交于 2019-12-10 10:26:34
问题 quick question about using ORMLite. I am trying to make sure that my implementation is correct. There's a part of the documentation that talks about closableIterators and how accessing this loads the LazyForeignCollection class and it needs to be closed (or read to the end) for the database connection to be closed: NOTE: Like with the Dao.iterator() method, the iterator returned by a lazy collection must be closed when you are done with it because there is a connection open to the database

Access as a front-end to SQL Server - ADO vs DAO?

依然范特西╮ 提交于 2019-12-10 08:32:34
问题 I have a project that will be using Access 2003 as the front-end and the data will be stored in SQL Server. Access will connect to SQL Server via linked tables with all the database logic (stored procedures, views) within SQL Server. Given this setup, would it be better to use ADO or DAO within Access? Is it just a matter of preference or is one more suited to Access as a front-end and SQL Server as the data store? Especially when using linked tables. Thanks. 回答1: Write pass-thru queries as

greenDAO讲义(一):使用篇

♀尐吖头ヾ 提交于 2019-12-10 00:38:02
目前android开发刚学习了一个多月,最近开始研究三方开源框架的用法。 了解android开发的人应该都会知道,android的数据库开发主要用到sqlite(如果这点你不清楚,那这篇文章就直接pass吧)。 greenDAO应该算是当前最火的数据库开源框架了吧,它是一个移动开发的ORM(object / relational mapping)框架,至于ORM是什么,可以百度之,本人理解也不是很深,大概意思就是为懒人设计的能够将对象和关系以映射的方式表达出来。greenDAO就是如此: greenDAO will do the word for you: it maps Java objects to datebase tables(often called ORM). 这样开发人员就可以吧精力集中在软件开发上,减轻了"wrting sql and parsing query results" 等等这些"quite tedious tasks". 总之,一句话,greenDAO就是实现Java对象和SQLite Datebase的一个媒介人,简化了SQLite的操作。 注:官方网站 http://greendao-orm.com/ 1. 下载greenDAO 要使用肯定要先下载他的软件包了,官网上有它的连接,对于marven和gradle环境直接到serarch.maven

dao设计模式

一笑奈何 提交于 2019-12-09 22:50:29
具体内容 DAO:数据访问对象:Data Acess Object,即:使用对象的形式操作数据库。 ###DAO组成: VO:每一个VO对象可以表示出一张表单一行记录,此类的名称要与表单名称一致。 DAO:操作接口:每一个DAO操作接口中规定了,一张表在一个项目中的具体操作方法,此接口的名称最好按照以下格式编写:I表名称DAO 里面的所有方法按照以下的命名编写: 更新数据库:doXxx() 查询数据库:findXxx或者getXxx 实现类中应该完成具体的CRUD操作。 此实现类完成的只是数据库中最核心的操作,并没有专门处理数据库的开发和关闭,因为这些操作与具体的业务无关。 代理类完成数据库的打开与关闭操作,并调用真实主题类。 有接口就必须有工厂进行解耦合。 注意: 在java的WEB开发中,jsp页面永远不许导入java.sql包,只能导入两种包: Java.util.*包 Vo包 DAO完成之后,实际上就可以按照一个组件的方式 ###总结 在使用DAO进行程序开发的时候,可以很好的将显示端与具体的代码端进行区分,显示只是从java代码中取出数据,而Java代码完成的只是一个个都业务模型, 很好的达到了显示和业务的分离。 来源: oschina 链接: https://my.oschina.net/u/221585/blog/676983

Most effective way to reflect inheritance relationship in DAOs?

a 夏天 提交于 2019-12-09 13:51:21
问题 Working on a business application using MVC structure and a Business Object / DAO architecture. For any normal business object, the CRUD functions are fairly straightforward. But what's the best way to handle a parent-child relationship like "Customer is a User"? I know that the following classes are involved: User, UserDAO, Customer, CustomerDAO The Customer class can inherit from the User just fine, but how do you best reflect this in the DAO CRUD functions? 回答1: Martin Fowler has

One DAO per thread or threadsafe DAO?

倾然丶 夕夏残阳落幕 提交于 2019-12-09 06:27:37
问题 I'm wondering if there's an approved practice in a multi-threaded app. Should I have one DAO per thread or simply make one DAO a thread safe singleton. 回答1: This really depends a lot on the mechanism you're using for data access. If you have a very scalable data access, and lots of threads, using some form of thread static data access can be advantageous. If you don't have scalable data access, your provider doesn't support multiple threads per process, or you just don't need the scalability

Adding and updating entities with Entity Framework

谁都会走 提交于 2019-12-09 04:24:43
问题 In my last project I have used Entity Framework 5 Code First. I completed my project but had a lot of pain during the development process. I tried to explain my pain below: I had several data classes in my data access logic layer like Product, ProductCategory, Order, Company, Manufacturer etc... Each class has some references to some other classes. For example, a Product instance has a ProductCategory property. Inside Add and Update methods of my Data Access Object classes I set the states of