mvc 2 « JPA « Spring Q&A

1. hibernate creates varchars not as utf8 although expected to do so

I'm using spring with hibernate and using mysql as my db. I set encoding in both hibernate and mysql as utf8 but when hibernate maps string fields to columns it creates ...

2. Spring MVC JPA lazy exception

I´m using JPA Hibernate and Spring MVC. I haved implemented repository pattern. I get a PageRepository that simply gets a Page object from the db. Then in the controller I'm trying to ...

3. sending bulk sms using springMVC

I am developing an application in wihch involvees sending sms to many mobiles using Spring MVC. Can anyone please help me in this regard. Please also tell me the if any ...

4. Bean creation using Spel + hibernate

We are using Spring MVC + its built in support for uploading files. I want to set the maximum upload size utilizing SpEL. The problem is this value comes ...

5. How to display null value error message in searching a data in jsp using spring mvc?

I have a table called accounts in which i am searching the data by account name, the search is working perfectly. Suppose if i am trying to search a which is ...

6. how to add a list of week for perticular shift which i am getting from selectbox

i have two column like week and shift in table, shift is integer type the shift i am getting from select box which having value as 149, and i have multiple ...

7. Open source Spring MVC/Spring/Hibernate projects that have high code quality?

In the line of Open source C# projects that have high code quality? What are some open source Spring MVC/Spring/Hibernate projects which I can download that implement many best-practices and have ...

8. Form input constraints not being enforced?

I'm new to Tomcat and Spring Web. I'm trying to use Spring's form validation features by following this tutorial. Everything seems to run smoothly except for one thing... my ...

9. HQL query not working, Incorrect syntax near ',' error. Using Spring and Hibernate

I am trying to execute following update query and getting error, Query is=

public List<Order> getClosedOrders(String userID) throws DataAccessException {
try { 

String SQL_SELECT_QUERY = "from Order as o where o.orderStatus='closed' and o.account.profile.userId='"+userID+"'";


10. Display image in Spring MVC

What is the proper way , using MultiActionController? I got in my Restaurant class:

private byte[] logo;
In my database I got table BLOB image. By using hibernate, it saves to my database properly ...

11. how to dynamically slect drop down list from hibernate query

Hi I'm new to spring and hibernate... how to dynamically select drop down list from first combo box into second combo box at run time from hibernate spring mvc web ...

12. json, hibernate and limited serialization

I am playing with a little web-app that is planned to have a presentation layer delivering json-encoded data. This app is backed by a couple of spring-services that fetch their data ...

13. Cannot disable enter key on a textarea

hi guys i am trying to disable enter key from submitting the form in a textarea using the following function:

function noenter() {
    return !(window.event && window.event.keyCode == 13); 

14. Spring webflow: how to keep track of persisted entity ids?

I'm working on a webflow (SWF2). The entities are generated using Roo. One of the webflow views, multi-instance.jspx, may be called multiple times to allow for multiple, persisted instances of the ...

15. Lazy Loadng error in JSON serializer

I have such kind of @OneToOne Hibernate relationShip

public class Address implements Serializable {

    private String id;
    private String city;
    private String country;
//setter ...

16. Spring MVC and Hibernate: How to print out left joined fields?

I'm new to Spring (MVC) and Hibernate... I got the following problem: I'm developing a RSS App which in short parse a RSS feed, store the fields in a database and displays ...

17. Hibernate and too many connections

I am working on web-project with Hibernate ans Spring MVC. My hibernate configuration is:

<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/xxx</property>
<property name="connection.username">xxx</property>
<property name="connection.password">xxx</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">1800</property>\<property name="hibernate.c3p0.max_statements">50</property>
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="connection.useUnicode">true</property> 
<property name="connection.characterEncoding">UTF-8</property> 
<property name="current_session_context_class">thread</property>
<property nam 

18. Updating of db data via form in Spring inserts duplicites

I have similar problem as is described in Spring Framework - New object is created in DB instead of updating but I have two entities: Author and Department in @ManyToOne ...

19. Hibernate + Spring exception: Unknown Entity

i am getting exception while the server starts. (Server is started using Intelij IDE). i have no idea how to fix it. i am new to hibernate and spring. thanks in advance.


20. Not-updatable child entity

I have such method:

public void add(User2 object) {
    Session session = SessionFactoryUtils.getSession(sessionFactory, false);;

    String number = generateNumber(object.getPerson().getId(), object.getPerson().getFranchise().getId());

21. My site doesn't load. Been working yesterday, today throws exception - form isn't working

I`m using spring + hibernate. Yesterday all has been working, I even added few users via "register.jsp". Saved project and ran it again today, something crashed:/ I`m using forms like those:

<form:form action="add.htm" commandName="user">

22. Spring MVC ManyToMany in MultipleSelect

I came across to problem with ManyToMany relations between Restaurant and Tag class. I got:

public class Tag {
    private int id;

23. Save Many-to-Many in Spring MVC

I got relation many to many between Restaurant and Tag. Here are my entities:

public class Restaurant {
    private int id;

24. Spring MVC load many to many relations

I got relations many to many between restaurant and tag. Here are my classes:

public class Restaurant {
    private int id;

25. Can't see entityManagerFactory

My application cant see entityManagerFactory. In my web.xml:


26. org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource

I'm new to spring mvc 3 and hibernate 3. i need some clarification for the following issue.I'm locked with this issue, so that i can't proceed to next step. This is my ...

27. Parse JSON record to extract key and value and put into Map in java

I have one column in my table which will store data in string format the sample data is

and the string contains data like json data but when i will send this record ...

28. Advice about using DAO/Spring MVC/Hibernate

I googled for few days to try to get the clear picture of how this works. I have few questions that I couldn't find clear answers to : -What is the advantage ...

29. (Hibernate configuration) cannot map classes located in other project

I have got couple questions about changing hibernate configuration. There is a project say ProA has got POJO classes i.e.

Hibernate config for ProA

30. Proper usage of Spring mvc 3 with hibernate (Spring ORM)

I'm starting a new project, trying to do things right this time(so more than one question), I might need some help, I'm not sure what I'm doing wrong :

  1. Spring ...

31. ehcache: query caching vs. method caching

I'm trying to decide whether to use query caching or method caching (with ehcache-spring-annotations) to cache the result of a few complex queries. The queries each hit lots of tables (with non-natural-key ...

32. What is the "correct" or "safe" way to update a persisted object with Spring MVC 3 + Hibernate?

Given a very simple object:

class User {
    private Integer id;
    private String name;

    public User() {}

    public Integer getId() ...

33. Json error in Spring

I tried this:

@RequestMapping(method = RequestMethod.GET, value = "/getmainsubjects")
public JSONArray getMainSubjects( @RequestParam("id") int id) {

List <Mainsubjects> mains = database.getMainSubjects(id, Localization.getLanguage());
JSONArray json = JSONArray.fromObject(mains);
return json;
} When calling getmainsubjects.html?id=1 I get the error:
net.sf.json.JSONException: ...

34. Spring 3 MVC : Cleanest way to retrieve dynamic information in the header and footer if they are includes

I am looking for the cleanest way to retrieve and display information in my headers and footers. They are .jspf includes inside my .jsp files. I know I could just boilerplate copy ...

35. Hibernate Lazy Load Error after merge

I'm using vanilla Spring MVC with a custom FlashScope implementation. We basically use it to follow the Post-Redirect-Get pattern. I've run into an odd situation. In my Post I do ...

36. Faceted Search Implementation using Hibernate Search + Spring MVC

I am looking for suggestions and working sample for implementing Faceted Search using Spring MVC and Hibernate Search.

37. Spring + Hibernate Lazy Load Error

I'm having an odd situation where I am getting a lazy loading issue on one of my controllers. Note: I am using the OpenSessionInViewInterceptor and am annotating my "service" layer ...

38. Spring - get all resolvable message keys

I have a web application which uses Spring MVC. I would like to have my interface consist of just a single page which retrieves all data dynamically as JSON via AJAX. ...

39. SpringMVC 3 Convert return String[] to Entity Object

I have an Entity Campaign that has a OneToOne relationship with CampaignCities cities. In turn, CampaignCities contains a Set cities; The campaign entity

    @javax.persistence.Table(uniqueConstraints={@UniqueConstraint(columnNames={"name","company_id"}), ...

40. Is HIbernate Seach worth for database Search?

My application is basically a people directory -lookup(about 1500 people) with all the information contained in database? I started to build this using SPRING-Hibernate and I arrived at the point to ...

41. Spring-HIbernate can't figure out query

There are three classes in db.. People(ID, FNAME, LNAME), Events(ID, NAME, DATE), Registrations(ID, P_ID, E_ID, REGDATE, NOTES) And my entity classes... People @Entity public class People{ ...

42. why do we always put Hibernate, Spring and Strut in one app?

Definitely, I'm talking about working with MVC pattern.
Definitely, Hibernate make our life easier with Model layer.
But, Spring and Strut both work with Controller and View.
So, my question is: "I cant ...

43. OpenEntityManagerInViewFilter Problems

I have scoured this site among others for answers in getting OpenEntityManagerInViewFilter to work. I have a standard User object that references a roles object with a many to many ...

44. Lazy initialize in Spring MVC

Despite using configuration below I got lazy initialize error:

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: beans.Restaurant.tags, no session or session was closed
<?xml version="1.0" encoding="UTF-8"?>" ...

45. HIbernate Criteria

I am having an issue with Hibernate Criteria when using If the list sent to the restriction doesn't have any values in it then it throws SQL GrammerException which is ...

46. Spring MVC: @ResponseBody, 415 Unsupported Media Type

I'm having trouble mapping a JSON Post to a particular Java Object to save it via Hibernate Headers of the Ajax call are correctly set...

Accept        ...

47. Many to one (item - type relation): identifer was change from x to y

I have 2 class Item & Type. An Item belongs to one type. It works ok. But when I try to change TYPE of an already saved item, it brings out the ...

48. Spring book for beginners

There maybe questions like that one but outdated, I want to learn spring, I don't know about spring or hibernate, what is the best books for beginners in spring? Also should ...

49. Replacing Hibernate /Spring / Spring MVC stack with Hibernate / Guice / Wicket

I have an application which are using Hibernate / Spring and Spring MVC, but as a motivation to learn and also compare the differences I want to port the application to ...

50. How to pass child class into controller in spring-mvc?

I have a parent class and its child in my application model.
And have the following controller method:

@RequestMapping(method=RequestMethod.POST, value="/page")
public String postMethod(Model model, Parent obj, BindingResult result) {
     // ...

51. Spring mvc SCA hibernate

question deleted.... question deleted.... question deleted.... question deleted.... question deleted.... question deleted.... question deleted.... question deleted.... question deleted.... question deleted....

52. Lazy Initialization Errors from Refreshes

How can I prevent LazyInitializationExceptions from being thrown when a page is requested multiple times? If I simply hold Ctrl-R on a page in my webapp, I consistently receive this ...

53. Can not populate drop down list using hibernate query in spring mvc

Here is my controller. In this I am using the reference data to send the List to my JSP page. Read the list into countryList which contains list of all country ...

54. Cannot find class [org.apache.commons.dbcp.BasicDataSource]

I am getting this exception when trying to start my spring MVC hibernate app.

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean ...

55. POSTGRESQL error working with Spring MVC/Hibernate 'Large Objects may not be used in auto-commit mode'

Of course this one seems easy enough per Here but I added the following to my application context...

<property name="dataSource">
    <ref bean="dataSource"/>

<property name="hibernateProperties">

56. When I try to run Spring MVC using STS then I get The requested resource () is not available

I am newbie in Spring MVC and Spring/Hibernate altogether. I am trying to run example which I found on net try to do it and not able to sucessfully run it. My web.xml ...

57. Hibernate: @GeneratedValue(strategy = GenerationType

I am using DB2 for my application. I run some insertion script after creating database. That insertion script generates records in table with id's given in insertion script. Suppose for abc table ...

58. Is domain model object passing between layers overhead?

I am working on a project that uses hibernate and spring. Hibernate is encapsulated in a DAO layer and the DAO layer has corresponding service layer as well, theres also the ...

59. Hibernate Exception: Connection Pool exhausted error after Spring upgrade

I am using Spring + Hibernate + Dbcp + Tomcat in my application. For some reason after a recent spring upgrade to version 3.0.6 the application has started to throw the ...

60. Error in mapping hibernate call using annotations

I am getting this ewrror.

Oct 15, 2011 6:30:11 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/AdministrativeApplication] threw exception [Request processing failed; nested exception is org.hibernate.hql.ast.QuerySyntaxException: tbluser ...

62. Hibernate Return integer value

I am new to hibernate . I want to pass 2 column values and want hibernate to return primary key of that table.

String queryString = "select perId from Permission where document.docId=1 ...

63. Hibernate Annotation join issue

I am trying to implement a simple join operation with my two tables ,using hibernate 3 annotaions with spring3 mvc. I have two tables:


CREATE TABLE IF NOT EXISTS `employee` (`enter code here`

64. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column

I have two table Student and Address.I am using hibernate 3 annotation for here.

My Student class


import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Table(name = "STUDENT")
public class Student {


65. Why doesn't my code update my entity object? Spring Hibernate MVC app

I have a Spring Hibernate MVC and trying to implement CRUD operations. I have gotten create, get, delete in a "RESTful" kinda way but I am having difficulties with update. When trying ...

66. Spring MVC - Hibernate : BLOB Image as byte array

This might be the dumbest question ever, but I have a weird issue and cant seem to get anywhere with this. Following is a jsp page where the current photo is ...

67. HQL with new object

Hello I have a HQL query like below in my DAO class.

String queryString1 = "select new,qc.questionCategoryName, qn.questionReferenceString, qn.question,qao.answerOptionGroupID,answerOptionGroup,answerStringValue) " +" from Questionnaire qn,QuestionCategory qc,QuestionAnswerOption qao,AnswerOptionGroup aog,AnswerString ...

68. How to edit a list of child entities in Spring 3 MVC

How would I edit an entity with child rows in Spring 3 MVC? I'd like a form like:

  <p>Parent name <forms:input path="" type="text" /></p>

69. Hibernate List is empty or null..What could be the reason

I do not see any exception in this piece of code. It runs fine yet when it returns there is no data in the List I call. getAll in the session ...

70. Spring-HIbernate: entity id before the entity is persisted

How do I retrieve the id of the newly persisted Entity before the transaction is complete when using @Transactional annotation.? Lets say I have a User table with it's id being generated ...

71. org.hibernate.TypeMismatchException: Provided id of the wrong type

I'm working for the first time with MyEclipse For Spring, which has hibernate support. Following the relevant part of the mysql db:

`delidete`.`DatiGeneraliVistoContabile` (
    `DatiGeneraliId` int NOT NULL, ...

72. Spring + Hibernate + Tuckey Urlrewrite = LazyInitializationException

Domain Description

I am using a combination of
Spring + Hibernate + Tuckey Urlrewrite
In a Spring Framework Web app. I have a simple data strucutre
Special has 1:Many Image object I am using the language in ...

73. HIbernate issue with Oracle Trigger for generating id from a sequence

We have a before insert trigger that gets the next value from sequence. When the object is persisted with save() method, hibernate gets the value from the sequence and adds it ...

74. Hibernate JPA, Spring MVC, Ext.form.Action.SERVER_INVALID

We have a web application that uses SpringMVC, Hibernate JPA and ExtJS. I added a column to the db table and changed the domain classes also.It's a boolean field. Now I ...

75. @Transient method call in Spring Hibernate

I have one Pojo class in which i create one field which is not mapped with DataBase Table. So i have to declare the field Declaration and setter and getter method @Transient,otherwise ...

76. spring-Hibernate: What is the best way to insert Audit Trails when updating associations?

I have a People table and 8 more People-relation tables and 9 Audit tables like below...

 PeopleSub (ID, PERSONID, SUBID, ...

77. spring framework tutorial using mysql database for a simple hello world application without using maven and hibernate in eclipse

I am new to spring and java. I am trying to learn spring framework for 1 months but i failed. Is there any small tutorials that uses mysql database with spring ...

78. Null entity field makes @PostUpdate method silently stop

I have a JPA domain entity that I'm updating from user input. Depending on lots of factors about that object, it has actions to perform when it's updated (in this case, ...

79. The database returned no natively generated identity value

I am using these technologies for my application. Spring MVC, Hibernate, DB2, Websphere In my Create Table script; ID column is generated as:

In Java Entity class its ...

80. Getting selectbox values on submit

In my application i have 3 tables user, userprofile and department. User Table :

  • User_Id
  • User_Type
  • User_Pswd
UserProfile Table :
  • Profile_Id
  • Profile_UserId (Foreign key linked to user table)
  • User_Name
  • Deapartment_Id (Foreign key linked to department table)
Department Table :
  • Dpt_Id
  • Dpt_Name
SelectBox for ...

81. Spring typequery finders with order by clause

Using Spring MVC 3.0 and roo, i'm tryin to write a custom typequery finder with an order by clause. This is what I've done thus far;

 public static TypedQuery<> findAllSessionInfosByScheduleOrderByDisplayOrder(Schedule schedule) {

82. Select Box value is null in controller

I have two tables one Department and other userProfile. In the jsp the commandName is mapped with userProfile table. And departmentId is the foreign key in userProfile. So in jsp i show ...

83. Insert data in two mapped tables in spring

I have 2 table user and userprofile mapped with each other. In getter method for userprofile is :

 @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
 public Userprofile getUserprofiles() {

84. Assignment of @GeneratedValue to otherthan ID column

I have a model like below:

@SequenceGenerator(name = "RA_QA_SEQ", sequenceName = "RA_QUESTIONNAIRE_SEQ")
public class Questionnaire {

    @GeneratedValue(generator = "RA_QA_SEQ")
    @Column(name = "QUESTID")

85. Execute named query using HibernateTemplate

I am developing a small application using Struts, Spring and hibernate3. But now I find trouble in executing named queries using HibernateTemplate. Here is my entity class,

@Table(name = "product")
@NamedQuery(name = "Product.findAll", ...

86. Spring MVC + ComboPooledDataSource (hibernate)

It's my first time I'm using ComboPooledDataSource in hibernate, but there's something wrong with my configurations I think, so that when I call DAO to retrieve all data from database this ...

87. Unable to execute native sql query

I am developing an application with Spring and hibernate. In the DAO class, I was trying to execute a native sql as follows:

SELECT * FROM product ORDER BY unitprice ASC LIMIT ...

88. Spring with Hibernate OR JSF with JPA

I know this is sort of very open ended question (mainly depending upon the requirement) . Which is better ---> Spring with Hibernate OR JSF with JPA. (not mixing the two) Other than ...

89. Downloading a file using extjs+spring

My application uses ExtJs as front end ans Spring MVC+Hibernate JPA as backend. I need to download a file. The url of the document is retrieved using the AJAX request.there is ...

90. org.hibernate.lazyinitialization exception

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: pojo.Person.address, no session or session was closed.
I am getting this exception and I'm using Spring 3.0 and Hibernate 3.6.

91. Can anybody solve this 500 Exception raised by Oracle Weblogic Server 11g

Error 500--Internal Server Error 
java.lang.NoSuchFieldError: org/apache/taglibs/standard/tag/common/core/ForEachSupport.deferredExpressionLjavax/el/ValueExpression;
    at org.apache.taglibs.standard.tag.common.core.ForEachSupport.release(
    at jsp_servlet._web_45_inf._jsp._admin.__newcustlist._jsp__tag1(
    at jsp_servlet._web_45_inf._jsp._admin.__newcustlist._jspService(
    at weblogic.servlet.jsp.JspBase.service(
    at weblogic.servlet.internal.StubSecurityHelper$

92. Hibernate Entity not being persisted

I am building a web app built on Spring MVC and Hibernate. I have an existing domain model and the application is largely working. I have a domain object called Status and ...

93. which maven's archetype to use for Spring MVC 3 - Hibernate - and JSP

Hi, which archetype to use for Spring 3 MVC application with Hibernate and JSP. Also I want know how I can know the list of jar's library that I need. Thanks. ...

95. Sts jpa mvc

I created mvc-template project and then i tried to add jpa to that project. instead it created a separate project. How can i include my mvc project jpa using STS?

96. Spring MVC Project + Hibernate dependency

Spring MVC Project + Hibernate dependency STS framework is pretty powerful and I am pretty impressed. I was trying to create a MVC project that uses Hibernate. The Spring MVC 3.0 ...

97. How to make spring mvc 3 application using hibernate (a simple CRUD operation appln)?

I use STS as IDE, I am using maven to build spring mvc 3 project. Whenever I am adding new dependencies, it is downloaded but when I am trying to use ...

98. Spring MVC - Child entity lost after submit

Spring MVC - Child entity lost after submit Hi all! First post on this forum, I hope someone can help me. I'm going to try to explain my problem as completely ...

100. Hibernate + Spring MVC + Annotations - Lazy Initialization Error Resolution

Hibernate + Spring MVC + Annotations - Lazy Initialization Error Resolution I have seen several people agonize over the Lazy Initialization Exception that appears when working with Spring MVC and Hibernate. ...