spring

In a mvc application, where will the DI take place?

When using spring and spring's MVC, where should the DI take place? example, if you have a controller, and many actions in the controller. Would you be doing: @RequestMapping("/blah") public String SomeAction() { ApplicationContext ctx = new AnnotationConfigApplicationContext(); MyService myService = ctx.getBean("myService"); ...

spring hibernate: save form object in relation

i have table users: relation many-to-many with table role, groups i use hibernate to map with my class; <hibernate-mapping package="cbs.domain"> <class name="User" table="users"> <id name="id" column="id"> <generator class="native" /> </id> <property name="username" /> <property name="password" /> <prope...

Using session scoped Spring bean with DWR

Spring: 2.5.6.SEC01 DWR: 2.0.5 I would like to use a session scoped bean from DWR. It works fine, when I configure the bean to be a singleton. I read this tutor: (http://directwebremoting.org/dwr/server/integration/spring.html) and modified my applicationContext.xml, but it is still wrong somewhere. My applicationContext.xml: http:/...

What is the cleanest way to autowire Spring Beans in a JSP?

Hi, We're currently adding some new features to an old webapp which was using only JSP without any framework for the front. We have added Spring recently, and we would like to autowire our beans in our modified JSP, while not rewriting everything to use SpringMVC, Struts2 or Tapestry5. We're using autowiring by type, so it leads to get...

using Spring JdbcTemplate

if i create a new instance of JdbcTemplate like so; JdbcTemplate jdbcTemplate = new JdbcTemplate(getDataSource()); by passing the datasource as a param (the datasource retrieves a connection from server connection pool) am i required to close the connection when im finished with it? In other words, if i have a pool of connections will...

Java + Command Pattern + Spring + remoting : How to inject dependencies to Command object ?

In my current project I'm dealing with EJBs implementing huge interfaces. Implementation is done through a business delegate, which implement the same interface and contains the real business code. As suggested by some articles like http://code.google.com/intl/fr/events/io/2009/sessions/GoogleWebToolkitBestPractices.html http://www....

JPA/Hibernate with Oracle Label Security

I have an application built with Spring and JPA/Hibernate that is working very well, but I now have a requirement to add Oracle Label Security. This will require the creation of a proxy user assigned with certain roles in addition to the actual user. I am unclear what goes into persistence.xml and what goes in code. Also, if we want to g...

How to check if an JPA/hibernate database is up with second-level caching

I have a JSP/Spring application using Hibernate/JPA connected to a database. I have an external program that check if the web server is up every 5 minutes. The program call a specific URL to check if the web server is still running. The server returns "SUCCESS". Obviously if the server is now, nothing is returned. The request timesout a...

After setting up the bean in the xml, how to you instantiate the object?

Once you have wired up the bean in the xml file, how to you instantiate the object? Is it just like: Myobject myObject = new MyObject(); And spring under the covers will perform the lookup based on the type? Or do you have to use the applicationContext? ...

Is it possible to pass a strongly typed model to a view/jsp page?

In spring mvc, I noticed the models are passed as a name/value pair into the ModelAndView. is it possible to create a strongly typed model and pass it to the view? this way the caller in the view can't access a string index that doesn't exist. ...

How load xml files, in IntelliJ IDEA

IntelliJ not find xml file under sources folder. example) src/net/saltfactory/domain/PersonSqlMap.xml but, If I copy it and past out folder, IntelliJ find xml file example) out/net/saltfactory/domain/PersonSqlMap.xml I hope that don't copy and past XML files to out folder help me ...

Spring + Hibernate : a different object with the same identifier value was already associated with the session

Greeting , In my non-web application(using Spring,Hibernate), I parse a CSV file and populate db using following method. handleRow() is called everytime a new raw is read from CSV file. My domain model: 'Family' has many 'SubFamiliy' 'SubFamily' has many 'Locus' a 'Locus' belongs to a 'Species' Family<>SubFamily<>Locus...

Spring: controller inheritance using @Controller annotation

I'd like to be able to create a base controller in my Spring app that, among other things, determines if a user is a registered user or not. This base controller, following the template design pattern, would contain an abstract protected method that controller subclasses would implement. The abstract method would have passed to it an ...

Lazy-loading with Spring HibernateDaoSupport ?

Greetings I am developing a non-webapplication using Spring+Hibernate. My question is how the HibernateDaoSupport handles lazy-loading , because after a call do DAO , the Session is closed. Take a look at following psuedo-code: DAO is like: CommonDao extends HibernateDaoSupport{ Family getFamilyById(String id); SubFamily getSubFamil...

Working log4j config ignored by Spring classes

Hi, I use log4j and he work just fine. A log4j.xml file is in my classpath, i use appender and category... again, it's work just fine for my code or code of other librairy. But the spring classes continue to flood stdout with message i want to log elsewhere. It's beggin to be anoying. Offending message : org.springframework.jms : som...

how can I integrate formBean to my Spring MVC?

My application is using Spring MVC. On the way from the Controller to the view we are taking adventage of this framwork by creating a bean of the model that is used to display the relevant properties through the JSP. On the way back however, meaning after submitting a form back to the controller, it is using a raw HTTPRequest instead o...

Problem with Hibernate find method

UPDATE: EXAMPLE TO CLARIFY I'm going to put an example of what's happening just to clarify the situation in my Spring + Hibernate application. Imagine I have this two entities (suppose getters and setters exists too) @Entity public class Class1(){ private Integer id; @OneToOne private Class2 object2; } @Entity public class Clas...

What is the best way to parameterise a Maven script to switch between Spring configurations?

What is the best way to parameterise a Maven script to switch between Spring configurations? I have Maven building a WAR file for a web app. I have alternative spring configurations - one for integration testing with mock objects, one for live production use with real objects. Ideally, I would like to have one Maven build script th...

Overview of the various java web view technologies

Generally speaking, what are the advantages/disadvantages of the various java servlet/spring-mvc view technologies? (jsp, freemarker, velocity, etc) E.g. is one faster than the other? More built-in support? flexibility? wide-spread usage? My use case is a cms type application. ...

Is there a performance hit with Spring if I use component-scan and make the base-package my root package?

I am using Spring 3. In my application context xml file I would like to use component-scan and start in my root package com.mysite and not explicitly add every package: would like to do <context:component-scan base-package="com.mysite"/> not: <context:component-scan base-package="com.mysite.util"/> <context:component-scan base-packa...