dao

Null values are insering in data base using Struts2 and hibernate

拟墨画扇 提交于 2019-12-04 17:16:24
I am using struts2 and Hibernate integration application to insert values in database. But after inserting values from form filed only null value is saving in database; this is my form jsp file employee.jsp <%@ taglib uri ="/struts-tags" prefix="s"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <s:form action="employee" method="post"> <s:textfield name ="name" label="ENTER your name"/> <s:textfield name="address" label="Enter Address"/> <s:submit label="submit">submit</s:submit> </s:form> </body> </html>

对于MVC的理解

淺唱寂寞╮ 提交于 2019-12-04 14:31:21
MVC模式:按照我自己的理解就是为了方便代码的管理。 M:model 业务逻辑层 service层:用来做逻辑处理,调用dao里面的方法得到数据。 dao层:操作数据库,调用写了的数据库工具类连接数据库,操作数据。 V: view 视图层 前端页面 C:controller 控制层 servlet接受前端发来的请求,然后发出响应给前端。调用service的方法来实现逻辑。service调用dao层的方法得到数据库中的数据。 dao层和service里面最好写一个接口,用接口的引用来调用实现类中的方法。 来源: https://www.cnblogs.com/yindong2019/p/11870322.html

EntityManager injection - NullPointerException

只谈情不闲聊 提交于 2019-12-04 14:05:58
问题 In my Spring+JPA/Hibernate+Wicket app, I have a QueryBuilder bean that I want to use in one of my DAOs which generates a typed query with the help of Criteria API: @Service(value="inboxQueryBuilder") public class InboxQueryBuilder { @PersistenceContext EntityManager em; CriteriaBuilder cb; public InboxQueryBuilder() { cb = em.getCriteriaBuilder(); } public TypedQuery<App> getQueryForApps(AppSearchObject aso) { ... } ... } However, when I run the app, I get a null pointer exception for line:

Converting DAO Recordset to Disconnected ADO Recordset dbDecimal Issue

99封情书 提交于 2019-12-04 13:07:33
In MS Access VBA (2007), I've written the functions below to convert a DAO recordset to a disconnected, in-memory ADO recordset. The problem is that I'm having data type conversion problems on the DAO dbDecimal fields. The problem shows up when I try to insert data from the DAO recordset into the newly created ADO recordset. When I get to the column that is type DAO dbDecimal (ADO adNumeric) I get the following error: Error -2147217887 (80040e21): Multiple-step operation generated errors. Check each status value. I've looked and the error happens every time it gets to this column. The data

Update linked tables in MS Access Database with C# programatically

非 Y 不嫁゛ 提交于 2019-12-04 12:40:53
I have two Access 2003 databases ( fooDb and barDb ). There are four tables in fooDb that are linked to tables in barDb . Two questions: How do I update the table contents (linked tables in fooDb should be synchronized with the table contents in barDb ) How do I re-link the table to a different barDb using ADO.NET I googled but didn't get any helpful results. What I found out is how to accomplish this in VB(6) and DAO, but I need a solution for C#. David-W-Fenton If you're coding in C#, then Access is not involved, only Jet. So, you can use whatever method you want to access the data and then

Hibernate opening/closing session, the correct approach for DAO

拥有回忆 提交于 2019-12-04 12:08:40
I have written this Hibernate object DAO, however with this approach, it is using session per update approach (which I don't think it's right). The reason why I don't think its right because I am running into problems with my User class, which contains collections that are lazily fetched. Since when retrieving each User from the DAO, the session is closed. Therefore I cannot get my collections. From time to time, it is also doing a lot of unnecessary updates to the table because the object is detached. So are there any ways of fixing my DAO, like using getCurrentSession() ? import java.util

javaBean和数据层的DAO设计模式

人盡茶涼 提交于 2019-12-04 10:40:12
jsp:javaBean 一、javaBean简介 javaBean是使用java语言开发的一个人可重用的组件,在jsp开发中可以使用javaBean减少重复的代码,是一种特殊的java类,使用java语言编写,遵循javaBean API规范 优点 将html和java代码分离,这主要是为了日后的维护方便 减少代码重复 在jsp中如果要应用jsp提供的javaBean的标签来操作简单类,则此类要满足以下要求: 所有类都要在一个包中,在web项目中没有包的类时不存在的。 所有类必须是public修饰,这样才能被外界访问。 提供一个默认的无参构造函数。 需要被序列化并且实现了 Serializable 接口。 可能有一系列可读写属性。(可能的意思就是除了private修饰的字段,也可以有其他修饰符修饰的字段,但是必须至少要有一个private修饰的字段) 可能有一系列的 getter 或 setter 方法。 二、在jsp中使用javaBean 一个javaBean编写结束后,需要进行打包编译,那么存放到哪里呢? classes目录保存所有的javaBean,如果不存在则可以手动创建(WEBAPP/WEB-INFO/classes) 引入useBean 打包编译 直接使用javac -d.类名,根据该类的路径的定义来打包编译变为class文件,在web开发中

Write Less DAOs with Spring Hibernate using Annotations

我的梦境 提交于 2019-12-04 08:33:45
My Spring+Hibernate configuration files are small and super tight. I use auto scanning to find my model entities/daos. I don't want to have to write a DAO + DAOImpl for EVERY Entity in my hierarchy. Some may qualify to have their own, like if they have complex relationships with other entities and require more than basic CRUD functionality. But for the rest... Is there any way to circumvent the defacto standard? Say, something like a generic DAO, ex: http://www.ibm.com/developerworks/java/library/j-genericdao/index.html Then I can do something like GenericDao dao = appContext.getBean(

Using JSF, JPA and DAO. Without Spring?

自闭症网瘾萝莉.ら 提交于 2019-12-04 08:27:53
till now i still worked with JSF and JPA without DAOs. Now i'd like to use DAOs. But how can i initialize the EntityManager in the DAO-Classes? public class AdresseHome { @PersistenceContext private EntityManager entityManager; public void persist(Adresse transientInstance) { log.debug("persisting Adresse instance"); try { entityManager.persist(transientInstance); log.debug("persist successful"); } catch (RuntimeException re) { log.error("persist failed", re); throw re; } } } Have I to use Spring or is there a solution that works without Spring? Thanks. If your container doesn't inject the

Spring MVC: Generic DAO and Service classes

余生颓废 提交于 2019-12-04 08:11:22
问题 I am writting web in Spring MVC. I wrote all DAOs using Generic DAO. Now I would like to rewrite my Service classes. How can I write "Generic Service"? There are my DAOs: /* ################################# DAO ################################ */ package net.example.com.dao; import java.util.List; public interface GenericDao<T> { public T findById(int id); public List<T> findAll(); public void update(T entity); public void save(T entity); public void delete(T entity); } /* ------------------