hibernate

Override Hibernate Annotations

I am developing a Java Application that uses Hibernate and is connected to an Oracle instance. Another client is looking to use the same application, but requires it run on MS SQL Server. I would like to avoid making changes to the existing annotations and instead create a package of xml files that we can drop in depending on the environ...

Hibernate: What am I missing? Can't find @Id, instead @Index

Every example I have found uses @Id, but when I try to write my code, many of the annotations that I'm used to are gone, there are annotatoins like @Index, and the @Entity parameters have changed. I've looked through the Hibernate documentation, and can't find anything talking about changing all of their annotations, so am I looking at ...

Spring 3 MVC + MySQL: cannot store € character

Hi there, I have Spring 3 MVC set up with Hibernate and MySQL 5. In a web form, I enter a single character into a field, € (i.e. just the one character). When I then attempt to save the data, I get the following exception: java.sql.BatchUpdateException: Data truncation: Data truncated for column 'name' at row 1 'name' is a String on m...

Spring 3 Annotations - HibernateDaoSupport - Repository Requires Session Factory

I am getting an exception saying : java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required when trying to use the @Repository annotation on a HibernateDaoSupport class. The error message is straightforward, in order to create the Repository it needs a sessionFactory. However,I have defined a s...

ORM using Hibernate's annotations with Spring

Hi! I'm trying integrate spring with hibernate but catch exception on project start. Caused by: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="com.domain.Worker"/ My config: from spring <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="clos...

configure hibernate with spring

Hi! I'm trying integrate spring with hibernate but catch NamingException: Context is read only stacktrace WARNING: Could not bind factory to JNDI javax.naming.NamingException: Context is read only at org.apache.naming.NamingContext.checkWritable(NamingContext.java:903) at org.apache.naming.NamingContext.createSubcontext(Naming...

Spring Transactional Unit Tests - Hibernate Queries Not Rolling Back

I am using Spring 3, and Hibernate 3.5, I am not getting my transactions to rollback in the test environment, which has me worried they would not be rolled back in production either. Test Class: @ContextConfiguration(loader = MyConfigurationLoader.class) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollb...

Can annotation be added to decelerations

Hello All, Can we add annotations to the decelerations instead to the getter methods. I'm used to this @Column(name="Part_ID") public Long getPartId() { return partId; } Can we use it like this @Column(name="Part_ID") private Long partId; Thanks all. Ravi ...

hibernate startup error

I am getting a weird message printed to standard our when hibernate starts up and i am having trouble diagnosing it. here is the message that prints out (it shows up red in my eclipse console, so i believe that means it was written to standard error): initialPoolSize-> coercedPropVal: 1 maxIdleTime-> coercedPropVal: 1500 maxPoolSize-> ...

Suggest a good approach for targeting different databases and configurations for dev/test/qa with Maven2?

Hi I'm starting a new web development project with my team using Hibernate and Spring MVC. We will be building with Maven2 and use the NetBeans IDE. Our past projects have used ant for the build system. We will be using Atlassian Bamboo for our CI server. My question relates to the best practice for switching between dev/test/qa/product...

Hibernate or EclipseLink for JPA?

I was wondering if anyone has experience with the JPA2.0 implementation of any of those frameworks? Especially together with Spring3.x which comes with EclipseLink support. Do you use any of those frameworks and JPA2.0 for production? Any severe issues? ...

Web services and hibernate - how would you combine these two?

I would like to use hibernate for persisting objects through web services and am thinking of using hyperjaxb3 with Apache CXF. Do you have any other suggestion for this purpose? Edit: To clarify my question a little bit... I am using eclipse and wsgen, wsimport ant tasks to generate my service and client classes respectively. I am using...

What is the standard way to write a program to generate invoices?

Hi guys, I am building a billing system. The system needs to generate monthly invoices to Clients. What I am doing now is using a For loop to check all the clients their previous invoices and decide if it is the time to generate a invoice for the client. If there are huge number of clients in the database, I think it could be very ...

Fetch multiple onetoMany relationships Hibernate JPA

I am using Hibernate JPA 1.0. I have the following type of model and I consider manyToOne and oneToOne relationships "eagerly" fetched and oneToMany "lazily" fetched. I want to fetch Entity A and all its associations where a.id=? A oneToMany B B oneToOne C C oneToMany D B oneToOne E E oneToMany D B oneToOne F F oneToMany D ...

Not getting the object id consistently in grails/java

Hi Guys, I am trying to send an email to the customer whenever there is a new invoice generated. but to do that i need to get the id of invoice and customer. My problem is that the code which I am using to get the ids for invoice or customer is giving me inconsistent response, i mean it works sometimes and sometimes it does'nt here is ...

Simple file upload using Flex UI and Spring/Hibernate/BlazeDS backend?

I'm new to Flex and BlazeDS and I'm trying to implement a simple application which uses Flex on the front end and a Spring/Hibernate application on the back end, with communication between the two going over a BlazeDS channel. I'm seeking direction as to the best and/or simplest way to approach this. I have the UI set up in such a way ...

Inheritance mapping with JPA/Hibernate

This is a fairly lengthy (not overly complex) design question so please bear with me. I'm trying to implement a person/role management system with POJOs and JPA. I'm fairly new to ORM and this is mostly a mapping problem. I've got this working as POJOs and am comfortable with the caller-level API, but would now like to map it to a datab...

Sharing nHibernate and hibernate 2nd level cache

Is it possible to share the 2nd level cache between a hibernate and nhibernate solution? I have an environment where there are servers running .net and servers running java who both access the same database. there is some overlap in the data they access, so sharing a 2nd level cache would be desirable. Is it possible? If this is not ...

Using a Hibernate Session (Hibernate 3.2, Spring 2.0) to prevent idle transactions

We are using Spring 2.0, Hibernate 3.2, and PostgreSQL 8.4.2 with pgBouncer (we've also tried pgPool-II). We are occasionally getting "IDLE in transaction" queries which sit around and hang up our database ... they usually show up sometime in between 2:00am and 6:45am. I've been running into a lot of conflicting information online as t...

How to reconstruct sql query from a ResultSet

Somewhere way inside JBoss in a hibernate query I'm catching an error that leaves me with a ResultSet. This code is a plugged in custom data type. It would be nice if I could simple do rs.getStatement().toString() and be done with it, but that unfortunately doesn't give away anything about the sql statement that went into it. I was thi...