DAO 1 « Database « Spring Q&A





1. How to design DAOs when the datasource varies dynamically    stackoverflow.com

Usually when defining a DAO, you would have a setter for the datasource on the DAO object. My problem is that our datasource varies dynamically based on the request to the server. ...

2. Using Spring managed DAO without controller?    stackoverflow.com

I'm trying to get my Portlets work with some DAO Objects which I configured as spring beans. I've included an application.xml to my WEB-INF, added it to my web.xml, configured hibernater ...

3. generic dao architecture discuss-best prastice    stackoverflow.com

i thinking of doing this architecture genericdao +interface ---> servicelayer+interface---> view layer my dao will only have generic methods, my service layers will have real logic for instance

service layer method

string ...

4. AbstractTransactionalJUnit4SpringContextTests: can't get the dao to find inserted data    stackoverflow.com

I'm trying to set up integration tests using the AbstractTransactionalJUnit4SpringContextTests base class. My goal is really simple: insert some data into the database using the simpleJdbcTemplate, read it back out ...

5. How to use SQLErrorCodeSQLExceptionTranslator and DAO class with @Repository in Spring?    stackoverflow.com

I'm using Spring 3.0.2 and I have a class called MovieDAO that uses JDBC to handle the db. I have set the @Repository annotations and I want to convert the SQLException ...

6. Spring Framework JDBC DAO with agrgegation/composition    stackoverflow.com

I have an application that is already using the Spring Framework and Spring JDBC with a DAO layer using the SimpleJdbcTemplate and RowMapper classes. This seems to work very well with ...

7. Spring JDBC DAO    stackoverflow.com

Im learning Spring (2 and 3) and i got this method in a ClientDao

    public Client getClient(int id) {
    List<Client> clients= getSimpleJdbcTemplate().query(
    ...

8. Law of Demeter and DAO pattern    stackoverflow.com

Here's a method in my Spring/Hibernate website's code that exemplifies my codebase:

public class UserVoteServiceImpl implements UserVoteService {

   @Autowired UserRepository userRepository;

   public static int getUserScore(long userId) {
  ...

9. Abstract DAO pattern and Spring's "Proxy cannot be cast to ..." problem!    stackoverflow.com

I know this is very often asked , but I cannot find a working solution : This is my AbstractDAO :

public interface AbstractDao<T>
{
  public T get(Serializable id);
  //other CRUD operations
}
And ...





10. Is it OK to have singleton DAO objects?    stackoverflow.com

Consider the following classes' structure:

  1. BaseDAO with methods to crest PreparedStatement and get connection from pool
  2. AccountDAO extends BaseDAO to work with Account table via JDBC. This class is singleton
  3. AccountService witch calls methods ...

11. EHCache implementation with Spring DAO    stackoverflow.com

I am trying to implement EHCache with Spring DAO . I have a requirement where i need to show the same output when coming form 2nd JSP page to 1st JSP ...

12. org.springframework.dao.DataIntegrityViolationException    stackoverflow.com

while adding some data to table from jsp, only one row of data gets inserted Also an org.springframework.dao.DataIntegrityViolationException is thrown. Can you say why this exception is raised?

13. Generic jdbc dao without getMetadata call    stackoverflow.com

is there a simple plain recursive resultset extractor (jdbc dao) that doesnt use the getMetadata or the column names and column count from resultSet? All the generic dao's use metadata for non-recursive ...

14. What is the purpose of distancing DAO classes from ones actually being instantiated by the application    stackoverflow.com

What is the benefit of distancing DAO classes from the ones actually being instantiated in the application code, i.e. why not just instantiate the dao class straight up in a scenario ...

15. Migrating to DAOs and Spring from Servlets and JDBC, advice?    stackoverflow.com

We've got webapps with servlets that make JDBC calls directly. We've mostly replaced the JDBC calls with Spring JDBC which has been a vast improvement (no more leaked connections!). I'd like ...

16. Why won't this dao class autowire?    stackoverflow.com

Please look at the files below and tell me why the Dao will not autowire. It autowires correctly when the same setter is put in a controller. I put ...





17. How can I mock out various result sets in my unit tests when we're using Spring to autowire the DAO?    stackoverflow.com

Let's say I have a manager that looks something like this:

public class CustomerManager {

    @Autowired
    @Qualifier("customerDAO")
    private CustomerDAO customerDAO;

    ...

18. What causes a NotSerializableException?    stackoverflow.com

My dao implementation is throwing a not serializable exception on server start up with Tomcat7. Any idea what causes this? None of my other daos are doing this. Here's the ...

19. Problem about controller and dao functions    stackoverflow.com

i made some small project there are just add, delete, showlist functions add and delete functions good work but get list functions are didn't work. (in my project memoservice.getAll() function didn't work well) so i ...

20. DAO class declared in ApplicationContext (Spring)    stackoverflow.com

I have been looking into some existing code of the company I am with and what i see is applicationContext.xml file has UserDAO class declared as a bean which is fine ...

21. DAOs with spring JDBC templates : Best way to unit test    stackoverflow.com

What is the best way to unit/integration test DAO layer classes built using Spring JDBC templates? Three approaches come to mind: 1) Mock library (EasyMock, JMock, Mockito, etc) - Spring framework test code ...

23. Best Practises For Dao    forum.springsource.org

Best Practises For Dao Hello. we are currently using Eclipse Link as JPA provider. We have created an entityManagerFactory in xml and are injecting it in our Dao, creating entitymanagers out ...

24. Dao pointcut not working?    forum.springsource.org

Dao pointcut not working? Hi guys, I've got an aspect, controller, service and dao. Below is a simplified example, but one I have actually coded into my project and run: ====================================== ...

25. Domain Object, Action and DAO defined in the sample Petstore    forum.springsource.org

Domain Object, Action and DAO defined in the sample Petstore Hi, A question regarding to the Petstore example included in the Springframework distribution package (Struts implementation): 1. Is it a common ...

26. Is there any difference between DAO and IOC?    forum.springsource.org

Hi everyone: I am new to Spring . There is an problem puzzled me some time. I use DAO pattern in this way before: Code: ITradeDAO tradedao=DAOFactory.getInstance().getTradeDAOInstance(); // use the tradedao ...

27. how to retrieve relationships with jdbc-based dao    forum.springsource.org

how to retrieve relationships with jdbc-based dao Suppose I have the following domain objects: Code: class Owner { int id String name } class Vet { int id String name } ...

28. DAO Exception translation without @Repository    forum.springsource.org

Hello I cannot find any solutions for DAO exceptions translation without using @Repository annotation. How to achieve it only by XML configuration, is it possible at all?

29. ValueList + your own DAO    forum.springsource.org

This as copied from correspondance between Mattew Wilson (author of ValueList - http://valuelist.sourceforge.net/ ): Maybe I'm just in dire need of caffeine this morning, but I don't see how I can ...

30. DAO's with multiple dispatcher servlets    forum.springsource.org

DAO's with multiple dispatcher servlets Hi, I'm trying to combine MVC and Blazeds integration. So far I managed to get it working by using to dispatcherservlets, one for flex and one ...

31. Is it necessary to have a DAO layer anymore?    forum.springsource.org

Is it necessary to have a DAO layer anymore? To me it doesn't make any sense anymore. It made perfect sense using plain old sql statements or even JPA queries but ...

32. DAO generating    forum.springsource.org

33. Exception Handling for org.springframework.dao.DataIntegrityViolationExce ption    forum.springsource.org

Exception Handling for org.springframework.dao.DataIntegrityViolationExce ption Greetings My application is a file management tool. I have searched for ways to handle the org.springframework.dao.DataIntegrityViolationExce ption error and not found any references. My base ...

34. How to share a dataSource between OJB DAO and JDBC DAO    forum.springsource.org

How to share a dataSource between OJB DAO and JDBC DAO In our application, we have a Service that calls OJB DAO's and JDBC DAO's. The service is wrapped with the ...

35. Hibenate, Dao and Spring setup    forum.springsource.org

Hibenate, Dao and Spring setup Hi All I am having trouble with the way I have developed and deployed my Hibernate and Spring application. Firstly i created a project that contains ...

36. Null pointer exception while calling DAO method in controller    forum.springsource.org

Null pointer exception while calling DAO method in controller Hi, I tried a lot to over come java.lang.NullPointerException but i couldnt.Any one please guide me where i am wrong: I am ...

37. How can a DAO method enforce SERIALIZABLE isolation?    forum.springsource.org

Service methods are declared @Transactional (with the default transaction isolation level set at READ_COMMITTED). A few DAO methods perform read-analyze-update operations against the database. Only the DAO method has knowledge that ...

38. Generating DAOs Dynamically    forum.springsource.org

Generating DAOs Dynamically Hi All, I need an urgent help on my project.Currently I'm trying to generate the entites and DAOs on a JPA project.But what succeed with JPA tools ...

39. DAO Design Pattern: DAO Helpers    forum.springsource.org

DAO Design Pattern: DAO Helpers I'm using version 2.5.X and am trying not to do anything too fancy. However, as I build more services that interact with the database, I am ...

40. Exception when DAO changed to implement interface    forum.springsource.org

Exception when DAO changed to implement interface I wanted to learn about annotations and followed the article here: http://technologicaloddity.com/2010/...h-annotations/ This is a Spring MVC example with Hibernate and Annotations built with ...

41. Need advice on IoC and DAOs    forum.springsource.org

Need advice on IoC and DAOs I'm trying to take an old DAO pattern and rewrite it for use with an IoC container. Here's my current architecture: * a util object ...

42. test integration for dao in JEE architecture    forum.springsource.org

test integration for dao in JEE architecture i want to implement a test for the dao classes, but while acting in the same way as in the spring by example (partIII.persistence ...

43. DAO for abstract class: Cannot instantiate abstract class or interface    forum.springsource.org

DAO for abstract class: Cannot instantiate abstract class or interface Hi everyone. Till today I have done my projects always and completely with Roo, but now I'm starting to use it ...

44. dao.save(object) - java.lang.NullPointerException    forum.springsource.org

@ContextConfiguration("/META-INF/spring/app-context.xml") public class PatientDaoImp { @Autowired private SessionFactory sessionFactory; public void save(Patient p){ Session session = sessionFactory.getCurrentSession(); session.save(p); session.flush(); }

45. Best practices for DAO    forum.springsource.org

Best practices for DAO I'm new with Spring, so sorry if this is a stupid question or has been covered before or if this is the wrong forum. I'm trying to ...

46. DAO design pattern    forum.springsource.org

DAO design pattern I'm just embarking on a new project and I'm kind of new to the hibernate/spring integration side of things and was just wondering what the best DAO design ...

47. Design of DAOs with Persistence Layer Differences    forum.springsource.org

Design of DAOs with Persistence Layer Differences This is a question that I always have a hard time answering. Therefore, I am turning to the Spring community and their wealth of ...

48. Problem about controller and dao functions. Help plz!    forum.springsource.org

Aug 31st, 2011, 12:02 PM #1 jw43834 View Profile View Forum Posts Private Message Junior Member Join Date Aug 2011 Posts 1 Problem about controller and dao functions. Help plz! I ...

49. Reverse lookup in Dao for the methods from its DaoImpl    forum.springsource.org

Hello, If Dao defines a method, its DaoImpl must implement it; otherwise STS will show an error. However DaoImpl could have some extra methods that are not present in its Dao. ...

50. 'New'ing model with dependencies from DAO    forum.springsource.org

'New'ing model with dependencies from DAO Hello, I think I am thinking about this too hard. I have a DAO (with @Repository that gets injected into my Controller via @Autowired). Inside ...

51. business layer vs dao layer    forum.springsource.org

business layer vs dao layer from what i've seen, the business layer methods delegate to dao methods with the same signature. where is the value doing that? Can you give me ...

52. DAOs with dynamic data source    forum.springsource.org

DAOs with dynamic data source I'm currently using Spring/Hibernate with an ApplicationContext. My DAOs use inversion of control (HibernateTemplate) and they are all wrapped by proxies provided by TransactionProxyFactoryBean. Everything works ...

53. DAO integration tests - creating and destroying database    forum.springsource.org

DAO integration tests - creating and destroying database I am working on setting up some automated integration tests for my DAO layer using the AbstractTransactionalJUnit4SpringContextTests class in Spring. I am using ...

54. is it possible to use same DAO's for different datasources    forum.springsource.org

is it possible to use same DAO's for different datasources I'm not quite sure how to go about this. I have a web appplication that uses the same table model but ...

55. Confused on domain objects vs transfert objects and DAO    forum.springsource.org

Confused on domain objects vs transfert objects and DAO Hi, After a lot of reading, including Rob's book and some topic on this board including http://forum.springframework.org/showthread.php?t=9818 I am quite confused on ...

56. Generic Dao and Controller component-scan    forum.springsource.org

Generic Dao and Controller component-scan Hi, I've made a quite simple generic Dao class. I define the Dao beans for all my entities like this: Code:

57. How to make a DAO be a @Repository without using the annotation?    forum.springsource.org

How to make a DAO be a @Repository without using the annotation? I have a set of DAO classes that I would normally add the @Repository annotation to, but I find ...

58. Transparent persistence tool and DAO pattern    forum.springsource.org

Transparent persistence tool and DAO pattern Hi, I have some troubles using transparent persistence tool with the DAO pattern. In my case I am using hibernate 1/ With automatic dirty checking, ...

59. Newbe dao question    forum.springsource.org

Hi All my Dao methods throws DataAccesException. Should my bussiness methods (which are only call these dao methods) throw DataAccessException too? What is the preffered way to handle exceptions came from ...

60. howto copy object multiple databases w/ multiple Hib. DAOs    forum.springsource.org

howto copy object multiple databases w/ multiple Hib. DAOs Hi all. I'm having problems copying instances of an object from one database to another using Hibernate and Spring. Has anyone done ...

61. Singleton or not to singleton in DAOs ?!    forum.springsource.org

Singleton or not to singleton in DAOs ?! Hello all ! My doubt is about singletons and or prototypes. 1) Simple domain objects(beans) should always be prototypes ?! 2) DAOs should ...

62. ACL DAOs    forum.springsource.org

ACL DAOs Hi: I have an application with multiple classes that use ACL-permissioning to control access to individual instances. I would prefer to keep the ACL info for each domain class ...

63. One-to-Many DAOs Please help!    forum.springsource.org

One-to-Many DAOs Please help! Please Help Trying to get started with Spring-Hibernate and Java DAOs. I was able to create a many to one mapping, but doing things the other way ...

64. How should I process Exception in DAO?    forum.springsource.org

How should I process Exception in DAO? Hi friends: I want to know how to process Exception in DAO layer. For example.there are two method to do this: one method: Code: ...

65. org.springframework.dao.InvalidDataAccessApiUsageE xception:    forum.springsource.org

Mar 12th, 2005, 10:55 PM #1 cracker_jack View Profile View Forum Posts Private Message Junior Member Join Date Oct 2004 Posts 8 org.springframework.dao.InvalidDataAccessApiUsageE xception: Hi All, I am trying to integrate ...

66. discuss a dao pattern - a friend suggest me    forum.springsource.org

discuss a dao pattern - a friend suggest me 1 create a BaseDao extends HibernateDaoSupport public class BaseDao extends HibernateDaoSupport{ private Log log = LogFactory.getLog(getClass()); public Session openSession() { return SessionFactoryUtils.getSession(getSessionFactory() ...

67. I don't know the correctness of this Dao pattern    forum.springsource.org

I don't know the correctness of this Dao pattern few days ago , a friend tell me a Dao pattern , but I don't know whether it can use in the ...

68. getting Dao from applicationContext    forum.springsource.org

getting Dao from applicationContext I'm working on a webapplication that is using an ejb session facade. I don't want to make my ejb layer "Spring aware" (yet). But this isn't the ...

69. Standalone app and Spring powered DAO?    forum.springsource.org

Standalone app and Spring powered DAO? I posted a similar question in JavaLobby and later found this to be proper place for Spring questions. http://www.javalobby.org/java/forums/t17910 Standalone Swing application, JDBC connection to ...

70. Adequation of ORMs and "DAO Pattern", PetClinic ex    forum.springsource.org

Adequation of ORMs and "DAO Pattern", PetClinic ex Hello, I wonder if the "DAO", or "Data Mapper" design patterns are appropriate to use with ORM tools such as Hibernate. Indeed, I ...

71. DAO paths relative to Tomcat installation    forum.springsource.org

DAO paths relative to Tomcat installation Working with a spring app that requires access to dynamic configuration and data files, I need to make sure that all path references are relative ...

72. Design issues about DAO    forum.springsource.org

Design issues about DAO Hi there, The project I am taking part in uses spring with hibernate for data access. We are trying to design the project according to common patterns. ...

73. Single dao to multiple data sources    forum.springsource.org

Single dao to multiple data sources Hi all. There is a data access interface for retrieval of read only static data. This interface is implemented by a JdbcDaoSupport which uses a ...

74. Any non web- and DAO-oriented tutorials out there?    forum.springsource.org

Any non web- and DAO-oriented tutorials out there? I have read a lot of the documentation available on this website, done some searching in Google, looked in the forums and have ...

75. Mixing DAO technologies    forum.springsource.org

Mixing DAO technologies I am converting an application to Spring DAO from a homebrew data access solution that amounts to wrappers around JDBC. I've created DAO interfaces. My initial implementations of ...

76. DAO Support without EJB Support    forum.springsource.org

DAO Support without EJB Support Hello, I have an EJB Session and I want to use the Spring DAO support in my business methods without exntends the class "org.springframework.ejb.support.AbstractStatefulS essionBean"... Is ...

77. Any existing Dao impl for writing to text file?    forum.springsource.org

Hi, Is there an existing AuthenticationDao implementation that reads/writes a local text file, applying a PasswordEncoder so the passwords are not plain text? This seems like a very basic requirement so ...

78. remote persistence DAO    forum.springsource.org

remote persistence DAO I'm developing an n-tier application that even if mainly non -web based resemples the layer structure of Appfuse, I guess is quite a common pattern to use a ...

79. Domain objects with no dependencys on DAO's    forum.springsource.org

Domain objects with no dependencys on DAO's Hi, I have a partitioning question that I'd some feedback on. Our app uses Spring, Struts and Hibernate, and I'd like to keep our ...

80. Several DAOs extending from one BaseDAOClass    forum.springsource.org

Several DAOs extending from one BaseDAOClass I asked this question together, but nobody answer. I'll try to improve my question. I have a BaseDAOClass called: Code: public class BaseDaoImpl extends HibernateDaoSupport ...

81. DAO Test cases    forum.springsource.org

DAO Test cases Hi All, I've written a simple POJO and DAO interface and hibernate implementation of the same using Spring. Here's how i've defined my DAO in the applicationContext.xml file. ...

82. how to test DAOs    forum.springsource.org

how to test DAOs Hi, maybe a little bit offtopic, but maybe you have some tips: how to testDAOs? After migration to hibernate 3, I found out, that some HQLs are ...

83. DAO configuration check    forum.springsource.org

If you want to make additional checks, you could write your own initDao() and call your own check methods from there. If you don't need additional checks you don't need to ...

84. Mr. Persister Spring Integration... how to integrate DAO's?    forum.springsource.org

Mr. Persister Spring Integration... how to integrate DAO's? We are currently working on the Mr. Persister 3.1.0 and one of the features our users have been asking for is Spring integration. ...

85. [ request ] dao    forum.springsource.org

Please be more specific. Do you mean you want to use a bind variable with JdbcTemplate? In that case you use one of the overloaded methods that take a SQL string ...

86. Spring DAO w/JDK5 generics    forum.springsource.org

I'm surprised I haven't seen any discussion about this, but how does the Hibernate generic-based DAO example http://www.hibernate.org/328.html fit into the Spring philosophy? It would seem that the interface and impl ...

87. Exception: org.springframework.dao.InvalidDataAccessApiUsageE xception    forum.springsource.org

Exception: org.springframework.dao.InvalidDataAccessApiUsageE xception Hello, this is my first post in this forum and I'll try to explain what problem I'm having with springframework and Hibernate3. I have this hibernate transaction in ...

88. Nested classes as a Dao pattern?    forum.springsource.org

Nested classes as a Dao pattern? I've never been happy with package organizations I come up with. I don't like excessive depth and at the same time I also don't like ...

89. SLSB, DAO and hibernateSessionFactory management    forum.springsource.org

SLSB, DAO and hibernateSessionFactory management Hi Can someone please help me out here: We have SLSB CMT and our SLSBs are deferring their business logic to a pojo (using the spring ...

90. Using ValueList with methods in DAO    forum.springsource.org

Hi, I would like to know if there is a way to use valueList with methods defined in my DAO instead of writting sql statments in the the configuration files. Thanks ...

91. Dynamic Datasources/Daos    forum.springsource.org

Dynamic Datasources/Daos An application I am starting to work on requires that I am able to connect to many different databases. I plan on using the standard Dao pattern but my ...

92. my DAOs don't commit !    forum.springsource.org

my DAOs don't commit ! I use spring 1.2.6 with hsqldb 1.7.3 and hibernate 3. i have a simple DAO that extends HibernateDaoSupport and uses HibernateTemplate. When i perfom a simple ...

93. testing spring DAO    forum.springsource.org

Dec 19th, 2005, 05:29 PM #1 babu View Profile View Forum Posts Private Message Junior Member Join Date Dec 2005 Posts 4 testing spring DAO This is spring code for executing ...

94. Problems with accessing DAO in different jars    forum.springsource.org

Problems with accessing DAO in different jars Hi, I have recently started using Spring and I am trying to get some Spring and hibernate functionality to work. For example I have ...

95. Requesting Comments on my DAO Tests    forum.springsource.org

Jan 4th, 2006, 05:14 PM #1 russpitre View Profile View Forum Posts Private Message Member Join Date Sep 2005 Location Boston, MA Posts 57 Requesting Comments on my DAO Tests I'm ...

96. Junit DAO testcase problem - need help.    forum.springsource.org

Jan 6th, 2006, 12:11 AM #1 anaik View Profile View Forum Posts Private Message Junior Member Join Date Dec 2005 Posts 2 Junit DAO testcase problem - need help. Hi Folks, ...

97. Client-Server style app with existing DAO layer?    forum.springsource.org

Client-Server style app with existing DAO layer? Hi folks, I've been searching for the better part of the evening and haven't found anything, so it's time to ask the question. I've ...

98. org.springframework.dao.DataIntegrityViolationExce ption:    forum.springsource.org

Jan 14th, 2006, 11:51 AM #1 difranr View Profile View Forum Posts Private Message Member Join Date Jul 2005 Posts 63 org.springframework.dao.DataIntegrityViolationExce ption: I am using Spring 1.25 with Hibernate 2.1.x ...

99. Unit test DAO without the Database    forum.springsource.org

Unit test DAO without the Database I am having a VERY hard time finding a thread in this forum that covers this issue in a clear way. Here's what I want ...

100. javax.faces.el.EvaluationException: org.springframework.dao.InvalidDataAccessApiUsage    forum.springsource.org

javax.faces.el.EvaluationException: org.springframework.dao.InvalidDataAccessApiUsage Hi, any help would be appreciated..... I'm working on a user registration transaction and I'm at the point where I'm submitting the user to save to the db.... It ...