I try to execute several queries in one DAO-method. Test is FAILED (the data are not updated). Logs without exceptions.
public List<Domain> getNewDomains(final int maxAllowedItems, final Date timestamp) {
return getJpaTemplate().execute(new JpaCallback<List<Domain>>() {
@SuppressWarnings("unchecked")
public List<Do...
Hi,
I have created a table in MSSQL having following structure -
**Table Name - TestTable**
id (int) (Primary key)
name (varchar)
owner (varchar)
I have given Identity specification for column 'id' with auto increment with 1 for each new row. When I created iBatis artifacts for TestTable, the insert function is getting generated, in...
My problem is that my program only crashes when debugging using Visual Studio.
The background: My program comprising various modules accesses an Access 2007 database via one module. I installed Access 2010 to do some testing of it so we can see if we should use that runtime in a upcoming release. I built all my modules in debug and I ca...
The following are methods I currently have in an Abstract DAO class. If there are concurrent calls, are they safe as they are or should synchronization be used? I know synchronization should be used if there is a reference to an attribute outside the scope of a method but it's unclear to me how should things be handled with an outside re...
Hello
I'm a Spring newby. I use the @Transactional annotation for my dao methods:
@Transactional
public Person getById(long id) {
return new Person(jdbcTemplate.queryForMap(...));
}
@Transactional
public void save(Person person) {
jdbcTemplate.update(...);
}
and I've set up the transaction manager like this:
<tx:annotation-...
I'm using the Spring MVC to build a thin layer on top of a SQL Server database. When I began testing, it seems that it doesn't handle stress very well :). I'm using Apache Commons DBCP to handle connection pooling and the data source.
When I first attempted ~10-15 simultaneous connections, it used to hang and I'd have to restart the se...
I am trying to come up with a manageable way to handle exceptions in a DAO. Typically a method in my DAO looks like this:
public ArrayList fetchColors (String id)
{
//call iBatis SqlMapClient
//put results in a list
//return list
}
If an error happens in the above code then everything is written to server.log and on the f...
I have a chance to introduce NHibernate to my group by using it with some new components that are being added to a legacy application. I'm trying to get my head around using the DAO pattern with NHibernate, and am stumped with an architectural question.
In my fictional example, let's say I have CarDAO and a Car entity:
public interfac...
I'm trying to implement a Generic DAO using the Hibernates Context Sessions. Following was my shot:|
import java.io.Serializable;
public interface GenericDao<T, ID extends Serializable> {
/** Persist the newInstance object into database */
ID create(T newInstance);
/**
* Retrieve an object that was previously persisted to the da...
I'm trying to use Spring DAO with Hibernate for a web application. When I try to persist information in the DAO using
getHibernateTemplate().save("bar", bar);
I get the following in Tomcat:
org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert:
[com.enw.foo.domain.Bar]; nested exception is org.hibernate...
Hi!
Im learning Spring (2 and 3) and i got this method in a ClientDao
public Client getClient(int id) {
List<Client> clients= getSimpleJdbcTemplate().query(
CLIENT_GET,
new RowMapper<Client>() {
public Client mapRow(ResultSet rs, int rowNum) throws SQLException {
Client...
I have a problem with transactions in that annotating a service that calls a DAO with @Transactional throws an exception stating that the Session is not open. The only way I can get it working is by annotating the DAO with @Transactional. What on earth can be happening?
This is what I'd like to do but doesn't work:
class CustomerServic...
Ok. Quick background:
MS Access 2003 with 2003/2003 format MDB file upgraded from Access 97.
For the purposes of this example, there are two tables.
Table 1
Asset
ID - (text 20)
ParentID - (text 20)
Other fields
AssetRels
ID - (text 20)
When a record is added to Asset, the ID is added to AssetRels.
From Asset.ID to Ass...
Let's say I'm doing unit testing methods for a UserDAO. I'm writing the test for the UserDao's deletion method. I would first insert a user into the db, then call the deletion method, and verify if the object still exists.
My question is: for the deletion unit test, when I'm inserting a user to test, should I be calling the UserDao's in...
I'm a bit of a noob with DAO and SQL Server and I'm running into a problem when I'm trying to insert values into two tables that have a relation. The table Photos has a gpsId field which has a foreign key relation with the id field of the GPSLocations table. I want to create a new Photos entry linked to a new GPSLocation, so the code l...
I've JPA entities and need to perform logic with them. Until now a huge static database class did the job. It's ugly because every public interface method had an private equivalent that used the EntityManager, to perform transactions. But I could solve that having a static em too!
However i'm wondering if that's an appropriate design, es...
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) {
return userRepository.findUserById(userId).getScore();
}
}
I believe that this method...
I have two entity managers in my applicationContext.xml which corresponds to two different databases. I can easily query database1 with entityManager1, but when I try to access database2 with entityManager2, I am not getting any results. I am using Spring+Hibernate+JPA.
Here is my ApplicationContext.xml
<?xml version="1.0" encoding...
I'm working on an application that talks to an Access database via DAO. Normally I use CreateObject("Access.Application") to get a copy of Access, then refer to the database via Application.CurrentDb, which works fine. But for some activities we need to do this instead for speed (VBA written for clarity, though the app is actually in C...
I am currently using iBATIS.NET for a small application I am building. I like to create concrete Classes for my DAOs instead of using ISqlMapper directly and invoking named SQL statements. I am not using a Dependency Injection container of any sort, so ideally I have my DAOs set up as follows:
public abstract class AbstractDAO
{
///...