标签: dao

Swift 3 - 声明模拟 JSON 作为来自服务器的响应

我正在使用 swift 3.0 制作应用程序。但我有一个问题,因为在 API REST 中仍然没有实现该服务,我正在创建一个模拟 JSON 来继续工作。但正如您在图像中所有解释的末尾看到的问题是,我不知道如何声明 JSON“-.- .... 基本上程序将调用服务器并响应使用 JSON(现在我将其传递为“模拟”,您将在代码中看到它)。然后使用该 JSON 将其与 ObjectMapper 映射到某些模型(我传递代码),以便最终应用程序拥有一个对象。

声明模拟 JSON 时出错

这是我必须在 JSON 来自服务器时映射 JSON 的三个模型,或者在本例中是模拟 JSON。

第一个是“LegendEntriesModel”:

import Foundation
import ObjectMapper
import AlamofireDomain

class LegendEntriesModel: Mappable {


fileprivate var _id_snapshot:     String?
fileprivate var _date:            String?
fileprivate var _deliverables:    [DeliverablesModel]?



init(){}

required init?(map: Map) { }

func mapping(map: Map) {
    self.id_snapshot      <- map["id_snapshot"]
    self.date             <- map["date"]
    self.deliverables     <- map["deliverables"]
}

var id_snapshot: String {
    get {
        if _id_snapshot == "" { …
Run Code Online (Sandbox Code Playgroud)

mapping json dictionary dao swift

2
推荐指数
1
解决办法
4147
查看次数

如何通过 DAO 传递查询从存储过程检索输出值

我正在将 ADP 转换为 ACCDB(链接到 SQL Server 的表/视图),并且在 DAO 传递查询方面运气很好。我陷入困境的一个领域是从存储过程中检索 OUTPUT 参数。

SP有以下参数

(@IType int, @RetVal bit OUTPUT) 
Run Code Online (Sandbox Code Playgroud)

简单来说,处理逻辑如下

IF @IType = 1
    SET @RetVal = (SELECT ... 
. . . 
Run Code Online (Sandbox Code Playgroud)

没有返回任何记录。Access VBA 过程所需的只是 RetVal。

我在网上搜索过,解决方案倾向于将值写入表或使用 ADODB。

我真的想避免修改存储过程,因为更改必须传播到多个数据库。

另外,坚持使用 DAO 传递会很好,因为我已经开始走这条路了。

有什么方法可以实现这一点吗?

sql-server ms-access dao stored-procedures return-value

2
推荐指数
1
解决办法
2262
查看次数

JPARepository 接口是否涵盖了 Spring Boot 中 DAO 接口的职责?

我是 Spring Boot 新手,我有一个问题。我将这样介绍它。

DAO 是一种设计模式,它具有三个组成部分。那些是

  1. DAO 接口 - 用于声明需要在 DTO 上执行的方法
  2. DAO接口实现-用于从数据源(数据库)获取数据
  3. DTO(数据传输对象) - 用于保留数据以在层之间传输。

例如,如果我们得到学生。

学生.java (DTO)

public class Student {
    private String name;
    private int rollNo;

    Student(String name, int rollNo) {
        this.name = name;
        this.rollNo = rollNo;
    }

    //getters and setters
}
Run Code Online (Sandbox Code Playgroud)

StudentDao.java

import java.util.List;

public interface StudentDao {
    public List<Student> getAllStudents();
    public Student getStudent(int rollNo);
    public void updateStudent(Student student);
    public void deleteStudent(Student student);
}
Run Code Online (Sandbox Code Playgroud)

StudentDaoImpl.java

import java.util.ArrayList;
import java.util.List;

public class StudentDaoImpl implements StudentDao {

    //list …
Run Code Online (Sandbox Code Playgroud)

java dao jpa spring-boot

2
推荐指数
1
解决办法
3013
查看次数

如何集成测试使用spring + iBatis构建的DAO

我问了一个问题,其标题可能会产生误导,所以我将尝试用更详细的东西再次提出这个问题.(我知道问题似乎很长但请耐心等待我)

我正在尝试做什么:我只是想为我的DAO编写测试用例并使其工作.我知道我的DAO在容器(app服务器)内工作正常但是从测试用例调用DAO时它不起作用.我认为因为它在容器之外.

在我的spring-for-iBatis.xml中填充

<bean id="IbatisDataSourceOracle" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/RSRC/my/db/oltp"/>
</bean>
<bean id="MapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation" value="classpath:sql-map-config-oracle.xml"/>
  <property name="dataSource" ref="IbatisDataSourceOracle"/>
 </bean>
Run Code Online (Sandbox Code Playgroud)

在我的sql-map-config-oracle.xml中填充

<sqlMapConfig>
   <settings enhancementEnabled="true" useStatementNamespaces="true" />
 <transactionManager type="JDBC">
  <dataSource type="JNDI">
   <property name="DataSource" value="jdbc/RSRC/my/db/oltp"/>
  </dataSource>
 </transactionManager>
         <sqlMap resource="mymapping.xml"/>
</sqlMapConfig>
Run Code Online (Sandbox Code Playgroud)

我的抽象类:

public abstract MyAbstract {
    public SqlMapClientTemplate getSqlTempl() SQLException{
        public static final String ORCL = "jdbc/RSRC/PIH/eiv/oltp";
        try {
            ApplicationInitializer.getApplicationContext().getBean("MapClient");
            SqlMapClient scl = (SqlMapClient) ApplicationInitializer.getApplicationContext().getBean("MapClient");
            DataSource dsc = (DataSource) MyServiceLocator.getInstance().getDataSource(ORCL);
            return new SqlMapClientTemplate (dsc, scl);
        }
        catch (NamingException e)
        { …
Run Code Online (Sandbox Code Playgroud)

java junit spring dao ibatis

1
推荐指数
1
解决办法
4894
查看次数

如何使用JPA实现测试DAO?

我来自Spring阵营,我不想使用Spring,并且正在迁移到JavaEE6,但我测试DAO + JPA有问题,这是我的简化示例:

public interface PersonDao
{
  public Person get(long id);
}
Run Code Online (Sandbox Code Playgroud)

这是一个非常基本的DAO,因为我来自Spring,我相信DAO仍然有它的价值,所以我决定添加一个DAO层.

public class PersonDaoImpl implements PersonDao , Serializable
{
  @PersistenceContext(unitName = "test", type = PersistenceContextType.EXTENDED)
  EntityManager entityManager ;

  public PersonDaoImpl()
  {
  }

  @Override
  public Person get(long id)
  {
    return entityManager .find(Person.class , id);
  }
}
Run Code Online (Sandbox Code Playgroud)

这是一个JPA实现的DAO,我希望EE容器或测试容器能够注入EntityManager(就像Spring一样).

public class PersonDaoImplTest extends TestCase
{
  @Inject 
  protected PersonDao personDao;

  @Override
  protected void setUp() throws Exception
  {
    //personDao = new PersonDaoImpl();
  }

  public void testGet()
  {
    System.out.println("personDao = " + personDao); // …
Run Code Online (Sandbox Code Playgroud)

java testing dao jpa cdi

1
推荐指数
1
解决办法
9820
查看次数

MS ACCESS 2007 VBA:DAO记录集....如何查看返回集合中的所有"字段"

所以如果我这样做一个SQL语句:

sql = "SELECT * FROM tblMain"

     set rs = currentdb.openrecordset(sql)
Run Code Online (Sandbox Code Playgroud)

我可以用什么方法查看我刚创建的这个集合中的每个"字段名称".我收到一些非常奇怪的错误,说明在此集合中找不到该项目.

我知道该字段存在于表中,当我引用它时,我已经三次检查拼写,并且SQL应该拉动所有内容,但我想看到它.

是否有debug.print方法来查看所有这些字段

谢谢贾斯汀

ms-access vba dao ms-access-2007

1
推荐指数
2
解决办法
2万
查看次数

用Java编写Excel文件

我用Apache POI创建了Excel文件.

在我的数据库中,我有一个400人的列表.我想将他们的姓名和姓氏写入该Excel文件.

这是我的代码示例:

try {
    FileOutputStream fileOut = new FileOutputStream("C:/testExcelForJava/test.xls");
    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet worksheet = workbook.createSheet("POI Worksheet");

    // index from 0,0... cell A1 is cell(0,0)
    HSSFRow row1 = worksheet.createRow((short) 0);

    HSSFCell cellA1 = row1.createCell((short) 0);
    cellA1.setCellValue("Ad");
    HSSFCellStyle cellStyle = workbook.createCellStyle();
    cellStyle.setFillForegroundColor(HSSFColor.GOLD.index);
    cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    cellA1.setCellStyle(cellStyle);

    HSSFCell cellB1 = row1.createCell((short) 1);
    cellB1.setCellValue("Soyad");
    cellStyle = workbook.createCellStyle();
    cellStyle.setFillForegroundColor(HSSFColor.GOLD.index);
    cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    cellB1.setCellStyle(cellStyle);

    List<Driver> driverList = Dao.driverDao.queryForAll();

    for(Driver driver :driverList){

        String name = driver.getName();
        String surname = driver.getSurname();
        String birthDay = driver.getBirthDay();

        cellA1.setCellValue(name);
        cellB1.setCellValue(surname); …
Run Code Online (Sandbox Code Playgroud)

java excel dao apache-poi

1
推荐指数
1
解决办法
492
查看次数

程序运行中的Dropwizard会话

我试图坚持dropwizard应用程序启动的时间.

public class Main Application extends Application<MainConfiguration> {
private final HibernateBundle<DeployerConfiguration> hibernate = new       HibernateBundle<AppConfiguration>(App.class) {

public DataSourceFactory getDataSourceFactory(
        AppConfiguration configuration) {
    return configuration.getDataSourceFactory();
}


    @Override
    public void initialize(Bootstrap<AppConfiguration> bootstrap) {
    bootstrap.addBundle(hibernate);

public static void main() {
   final AppDAO ddao = new AppDAO(hibernate.getSessionFactory());
   App app = new App(new Date());
  adao.create(app);
Run Code Online (Sandbox Code Playgroud)

物体:

JsonIgnoreProperties(ignoreUnknown = true)
@Entity
@Table(name = "app")

@NamedQuery(name = "App.findAll", query = "SELECT d FROM App d")

public class App implements  Serializable{

  private static final long serialVersionUID = 1L; …
Run Code Online (Sandbox Code Playgroud)

java session dao hibernate dropwizard

1
推荐指数
1
解决办法
1489
查看次数

泽西构造函数与参数

我想在使用Jersey开发的RESTful服务中使用DAO,因此应该通过服务的构造函数注入DAO实现:

@Path("eventscheduler)
public class EventSchedulerService {
    private IEventSchedulerDao dao;

    public EventSchedulerService(IEventSchedulerDao dao) { this.dao = dao; }
}
Run Code Online (Sandbox Code Playgroud)

但是,我知道Jersey希望默认构造函数能够正确设置所有内容.我一直试图弄清楚如何做一段时间,但令人惊讶的是,这似乎是一个不常见的情况,我想知道人们如何将DAO注入他们的服务,或者根本不用处理注射.

我怎样才能做到这一点?

java rest dao dependency-injection jersey

1
推荐指数
1
解决办法
4010
查看次数

会议室数据库Livedata getValue()返回null

我试图使用LiveData和viewmodel从房间中获取自定义对象数据的列表。使用Livedata的getValue()方法时,返回null,但获取列表直接显示实际数据。如何在Viewmodel类中使用LiveData获得Period类的列表。

实体类

@Entity
public class Period {

@PrimaryKey
@NonNull
String header;
@TypeConverters(WritterConverter.class)
ArrayList<Writter> writters;

public Period(String header, ArrayList<Writter> writters) {
    this.header = header;
    this.writters = writters;
}

public String getHeader() {
    return header;
}

public ArrayList<Writter> getWritters() {
    return writters;
}


}

@Entity
public class Writter {

String birth;
String death;
String name;
ArrayList<String> novels;

public Writter(){}

public Writter(String birth, String death, String name, ArrayList<String> novels) {
    this.birth = birth;
    this.death = death;
    this.name = name;
    this.novels = novels;
} …
Run Code Online (Sandbox Code Playgroud)

android dao viewmodel android-room android-livedata

1
推荐指数
1
解决办法
3203
查看次数