spring

Is there anyway to get the generated keys when using Spring JDBC batchUpdate?

I am using JDBC and want to batch insert, but I need the generated keys for the next round of inserts - is there anyway to accomplish this? MapSqlParameterSource[] batchArgs .... DAL.getNamedParameterTemplate().batchUpdate("INSERT INTO...", batchArgs); Thanks ...

Post login execution

Hello, I need to do some processing only after the user has successfully logged in the system. I have thought that I can do a RESTful method and setting it as the default-target-url so when the login is successful it goes to this url and then I can redirect to the real index of my web application. <form-login login-page='/login.htm' d...

How to access sprint context in jUnit tests annotated with @RunWith and @ContextConfiguration?

I have following test class @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"/services-test-config.xml"}) public class MySericeTest { @Autowired MyService service; ... } Is it possible to access services-test-config.xml programmatically in one of such methods? Like: ApplicationContext ctx = somehowGet...

spring binding formmultiselect

I'm trying to bind multiselect to my object. The form is created and the post works and no errors occur when I don't select anything. If I select a language the object gets language value but the form breaks. HashMap<String, String> languages = new LinkedHashMap<String, String>(); languages.put("eng","english"); languag...

Spring 3 simple extentionless url mappings with annotation-based mapping - impossible?

Hi, I'm using Spring 3, and trying to set up a simple web-app using annotations to define controller mappings. This seems to be incredibly difficult without peppering all the urls with *.form or *.do Because part of the site needs to be password protected, these urls are all under /secure. There is a <security-constraint> in the web.xm...

OpenEntityManagerInViewFilter and testing the presence of an EntityManager

I posted a question a few days ago mentionning Spring's OpenEntityManagerInViewFilter: http://stackoverflow.com/questions/2385858/uirepeat-inside-a-uirepeat-and-lazyinitexception What I'd like to know is of a way to test if an EntityManager is available during a request. What is a good way of doing this? ...

Seam Equivalent of Spring PersistenceUnitPostProcessor

We have a very comfortable setup using JPA through Spring/Hibernate, where we attach a PersistenceUnitPostProcessor to our entity manager factory, and this post processor takes a list of project names, scans the classpath for jars that contain that name, and adds those jar files for scanning for entities to the persistence unit, this is ...

Spring @Transactional not creating required transaction

Ok, so I've finally bowed to peer pressure and started using Spring in my web app :-)... So I'm trying to get the transaction handling stuff to work, and I just can't seem to get it. My Spring configuration looks like this: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns...

JPA thinks I'm deleting a detached object

So, I've got a DAO that I used to load and save my domain objects using JPA. I finally managed to get the transaction stuff working (with a bunch of help from the folks here...), now I've got another issue. In my test case, I call my DAO to load a domain object with a given id, check that it got loaded and then call the same DAO to dele...

Newlines and Spring's SimpleUrlHandlerMapping

I recently upgraded my app from Spring 2.5.6 to Spring 3.0.0. A few days later, I noticed that some of my pages were no longer functional. The problem appears to be my UserContent.do controller. UserContent.do is mapped using the SimpleUrlHandlerMapping mapping. It looks like this: <bean id="urlMapping" class="org.springframework.we...

How to insert into two different tables in one statement with Java and MySQL?

I am using Java, Spring (NamedParameterJdbcTemplate) and MySQL. My statement looks like this: INSERT INTO Table1 (Name) VALUES (?); INSERT INTO Table2 (Path, Table1Id) VALUES (?, LAST_INSERT_ID()) But it is throwing the following error: PreparedStatementCallback; bad SQL grammar [INSERT INTO Table1 (Name) VALUES (?); INSERT INTO Tab...

Getting java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Exception

Hi , I am getting Following Exception while configuring the Connection Pool in Tomcat This is Context.xml <Context path="/DBTest" docBase="DBTest" debug="5" reloadable="true" crossContext="true"> <!-- maxActive: Maximum number of dB connections in pool. Make sure you configure your mysqld max_connections large en...

How to deal with the Hibernate hql multi-join query result in an Object-Oriented Way?

How to deal with the Hibernate hql multi-join query result in an Object-Oriented Way? As I see it returns a list of Objects. yes, it is tricky and only you who write the query know what should the query return (what objects). But are there ways to simplify things, so that it returned specific objects with no need in casting Object to a...

How to inject dependencies into HttpSessionListener, using Spring?

How to inject dependencies into HttpSessionListener, using Spring and without calls, like context.getBean("foo-bar") ? ...

ACL architechture for a Software As a service in Spring 3.0

I am making a software as a service using Spring 3.0 (Spring MVC, Spring Security, Spring Roo, Hibernate) I have to come up with a flexible access control list mechanism.I have three different kinds of users System (who can do any thing to the system, includes admin and internal daemons) Operations (who can add and delete users, orga...

Testing injected dependencies into your struts2 actions

Hi, I am wondering how others might have accomplished this. I found in the Spring documentation @required which I attempted to use in a 'test' but got this stmt INFO XmlConfigurationProvider:380 - Unable to verify action class [xxx] exists at initialization I have found another way in spring to do this is to write custom init methods a...

When using spring and hibernate, how are sessions/transactions handled?

when using hibernate with spring, can someone explain how the session unit of work and transactions are handled? is the transaction started at the beginning of the page request, and committed at the end? can I have multiple db calls per request, that each have different transaction levels? e.g. some are left as default, while others ar...

DDSteps date question.

DDStep Date Question: Currently trying to pass just the date from excel. But getting the below error while doing it. Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property ...no matching editors or conversion strategy found spring for date conversion I even tried to add customEditorCo...

How do I override a Spring bean definition yet still reference the overriden bean?

I'm attempting to implement a delegate Service provider by overriding the bean definition for the original service with my delegate Service. However, as the name would imply, the delegate Service needs a reference to the original service to delegate calls to. I'm having trouble figuring out how to override the bean definition while usi...

GAE, JDO, count() doesn't work ?

On GAE with Spring/JDO after saving 2 entities (in transaction). On calling getById - entities fetched from data storage. On calling getCount() returns "0" and - on calling getAll() - returns empty collection. @Override public Long getCount() { return ((Integer) getJdoTemplate().execute(new JdoCallback() { @Override public Obj...