dao

DAO and Data transfer object

删除回忆录丶 提交于 2021-02-19 08:15:07
问题 So in the Data transfer Object there should be only setters and getters.. However what about handling also inserting and deleting objects from the Data transfer Object? public class dto{ setters and getters... .. .. public void delete(){ CustomreDao.delete(this.ID); } } Would it be against the DAO pattern itself? Thanks in advance. 回答1: Ask yourself this: "how hard would it be to update the DAO's delete method?" If you have a lot of DTOs and suddenly need to change the DAO, then that's a lot

DAO and Service Layer with hibernate

痞子三分冷 提交于 2021-02-07 18:17:44
问题 im in trouble with implemenetation of a service layer, i think i did not understand this concept very well. In a DAO implementation i can write all CRUD logic for a specific technology and entity (for example hibernate and User table), and in a service layer we use a DAO for all data operation for the entity in DAO (like getUser, loginUser, etc..) is this ok? If this is ok i have a simple question, can i handle database connection (or in case of hibernate, session and transaction) within

Room DAO Order By ASC or DESC variable

帅比萌擦擦* 提交于 2021-02-07 04:54:40
问题 I'm trying to make a @Query function in my @Dao interface which has a boolean parameter, isAsc to determine the order: @Query("SELECT * FROM Persons ORDER BY first_name (:isAsc ? ASC : DESC)") List<Person> getPersonsAlphabetically(boolean isAsc); Apparently this isn't allowed. Is there a work around here? EDIT: It seemed odd to use two queries (below) since the only difference is ASC and DESC : @Query("SELECT * FROM Persons ORDER BY last_name ASC") List<Person> getPersonsSortByAscLastName();

How to check if room database is empty or not

孤者浪人 提交于 2021-01-29 11:10:37
问题 I am trying to check if room database is empty or not before making a network call. but it is showing below error. error: Not sure how to convert a Cursor to this method's return type (java.lang.Integer). What I have been doing is when app starts I am checking row count in room databse if it is null then I am making a network call. Below is my code. UserDao.java @Dao public interface UserDao { @Query("SELECT * FROM Users") LiveData<Integer> isDbEmpty(); } UserRepository.java public class

Migrating from obsolete DAO classes

早过忘川 提交于 2021-01-29 02:56:14
问题 I've got a C++ system developed in VS 2002/3 that I'm upgrading to current tech and it makes extensive use of CDAO classes (CDAODatabase, etc.). These are deprecated as of VS 2005 and unavailable in x64-compiled code. I can't figure out what data access classes i should be migrating to for this upgrade. Any suggestions? Is there a particular set of classes that I can just drop in and get the same functionality with minimal code updates? 回答1: Your options would be ODBC, OLE DB & ADO All of

Migrating from obsolete DAO classes

Deadly 提交于 2021-01-29 02:45:43
问题 I've got a C++ system developed in VS 2002/3 that I'm upgrading to current tech and it makes extensive use of CDAO classes (CDAODatabase, etc.). These are deprecated as of VS 2005 and unavailable in x64-compiled code. I can't figure out what data access classes i should be migrating to for this upgrade. Any suggestions? Is there a particular set of classes that I can just drop in and get the same functionality with minimal code updates? 回答1: Your options would be ODBC, OLE DB & ADO All of

MyBatis学习笔记二:增删改查

老子叫甜甜 提交于 2020-12-22 05:03:13
MyBatis基本的增删改查操作,有图有真相,项目截图[ MyBatis-0200 ] 项目依赖及表参阅 上一篇 [user.xml] <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!-- 命名空间:通常是Mapper接口的完整类路径,在MyBatis3.x中不可省略 --> <mapper namespace="net.yeah.likun_zhang.mapper.IUserMapper"> <!-- ======================================== eviction : 回收方式( LRU – 最近最少使用的:移除最长时间不被使用的对象(默认)。 FIFO – 先进先出:按对象进入缓存的顺序来移除它们。 SOFT – 软引用:移除基于垃圾回收器状态和软引用规则的对象。 WEAK – 弱引用:更积极地移除基于垃圾收集器状态和弱引用规则的对象。 ) flushInterval : 可以被设置为任意的正整数,而且它们代表一个合理的毫秒 形式的时间段。默认情况是不设置,也就是没有刷新间隔

How to fetch edittext value from one activity to recyclerview of next activity?

杀马特。学长 韩版系。学妹 提交于 2020-08-17 12:00:50
问题 I'm trying to fetch edittext value from one activity and displaying that text in recycleview and storing using room DB.... Basically the idea is adding the address in activity address when clicks on plus it will redirect to next page where the user gets the address form onsubmit it will fetch address and add to previous activity recycleview. here is my code for room: table:--- @Entity(tableName = "address") class Address { @PrimaryKey var id = 0 @ColumnInfo(name = "address") var address:

How to fetch edittext value from one activity to recyclerview of next activity?

妖精的绣舞 提交于 2020-08-17 11:59:18
问题 I'm trying to fetch edittext value from one activity and displaying that text in recycleview and storing using room DB.... Basically the idea is adding the address in activity address when clicks on plus it will redirect to next page where the user gets the address form onsubmit it will fetch address and add to previous activity recycleview. here is my code for room: table:--- @Entity(tableName = "address") class Address { @PrimaryKey var id = 0 @ColumnInfo(name = "address") var address: