hibernate

could not initialize proxy - no Session

HI, I am using Grails 1.2.1 and I always got this message when I run my apps and leave it without anyone using the apps. org.hibernate.LazyInitializationException: could not initialize proxy - no Session at H__project_ilinkdev_grails_app_views_layouts_main_gsp$_run_closure2.doCall(H__project_ilinkdev_grails_app_views_layouts_main...

Hibernate, Stored Procedures and Invalid Parameter Index Error

Hi, I have a SQL Server Stored Procedure that looks like this: CREATE PROCEDURE [dbo].[my_stored_procedure] ( @num INT, @name VARCHAR(50), @start_date DATETIME, @end_date DATETIME ) AS BEGIN ... END And an Entity Object with a NamedNativeQuery that looks like this: @Entity @NamedNativeQuery( ...

EJB3 Entity and Lazy Problem

My Entity bean has 2 list: @Entity @Table(name = "TABLE_INTERNAL") public class Internal implements java.io.Serializable { ...SOME GETTERS AND SETTERS... private List<Match> matchs; private List<Regional> regionals; } mapped one FetchType.LAZY and one FetchType.EAGER: @OneToMany(fetch = FetchType.LAZY,mappedBy = "interna...

Query problems with Hibernate (JPA) and PostgreSQL

I'm trying to use PostgreSQL as the database for Hibernate/JPA. However, I get an error when executing a simple query. My query is as follows: SELECT DISTINCT p FROM UserProfile p ORDER BY :order When I execute the query, I'll pass in a value like "lastLoginDate" for :order. However, I get the following exception when trying to exe...

Making ehcache read-write for test code and read-only for production code

I would like to annotate many of my Hibernate entities that contain reference data and/or configuration data with @Cache(usage = CacheConcurrencyStrategy.READ_ONLY) However, my JUnit tests are setting up and tearing down some of this reference/configuration data using the Hibernate entities. Is there a recommended way of having entiti...

Forcing a transaction to rollback on validation errors in Seam

Quick version: We're looking for a way to force a transaction to rollback when specific situations occur during the execution of a method on a backing bean but we'd like the rollback to happen without having to show the user a generic 500 error page. Instead, we'd like the user to see the form she just submitted and a FacesMessage that i...

Hibernate/JPA and PostgreSQL - Primary Key?

I'm trying to implement some basic entities using Hibernate/JPA. Initially the code was deployed on MySQL and was working fine. Now, I'm porting it over to use PostgreSQL. In MySQL, my entity class defines its primary key as an auto-incrementing long value with the following syntax: @Id @GeneratedValue(strategy = GenerationTy...

Multiple Grails Applications create Ehcache conflicts

I am running multiple Grails Applications on one of my servers. I am using Grails 1.2.2. I am using the default cache configuration in DataSource.groovy. When I try and run two Grails applications, they both seem to be using/writing to: /tmp/org.hibernate.cache.UpdateTimestampsCache.data When I look at how to customize Ehcache with an ...

Grails/Hibernate max for string type

Hello, In my table I have a serial number field, which is represneted by string.. It has a prefix and some numbers follow. Eg: ABC1234, ABC2345 etc. How to retrieve the largest value (max equivalent of int type) from this column. In my case it would be ABC2345. I probably could retrieve all the data,, sort it and get the same, but that...

AnnotationSessionFactoryBean and singleton scoped bean (Spring framework)

I define a bean of type AnnotationSessionFactoryBean for using in a web-app. If I do not explicitly define it as NOT singleton, it must be singleton. Now, it is bound to the current thread. It means it cannot be a singleton. p.s. Session produced by Factory is not a singleton, SessionFactory on the other hand is always a singleton. N...

POJOs for Composite Primary Key from Foreign Key

hi, I have table in database that has only two columns and these two colums are FK references. they have made these two colums as composite primarykey. table structure Table A [ A_id PK Description ] Table B [ B_Id PK Description ] Table A_B_Pemissiom [ A_id (FK table A) B_Id (FK table B) Primary...

What is second level cache in hibernate ?

What is second level cache in hibernate ? ...

how to use rownum in hibernate for greater or less

Hi, SELECT * FROM ABC WHERE PARATYPE = 'A' AND MODELID = '50' AND 'BA1' BETWEEN RAWMIN AND RAWMAX AND ROWNUM < 2 ; I have the above query .i have difficulty in converting rownum < 2 in plsql to hibernate query. Can u help me .it's urgent. Thank You. ...

Dozer mapping for Hibernate object to DTO

Hello, I try to use Dozer to convert my domain entity to DTO objects. So, I want to convert PersistentList, PersistentBag, ... from my domain entity to ArrayList, ... in my DTO objects to avoid lazy problem. This is an example of two of my domain entity : public class User { private Collection<Role> roles; ... } public cl...

Using Hibernate's ScrollableResults to slowly read 90 million records

I simply need to read each row in a table in my MySQL database using Hibernate and write a file based on it. But there are 90 million rows and they are pretty big. So it seemed like the following would be appropriate: ScrollableResults results = session.createQuery("SELECT person FROM Person person") .setReadOnly(true).set...

What is best approach for connection pooling?

I am implementing connection pooling in project. Performance wise which is better approach to do it? Hibernate (using C3PO or DBCP) Configuring JDBC data-source in Application server. Application server Portability is not an important factor for me. Please suggest the approach. ...

Why are transactions not rolling back when using SpringJUnit4ClassRunner/MySQL/Spring/Hibernate

I am doing unit testing and I expect that all data committed to the MySQL database will be rolled back... but this isn't the case. The data is being committed, even though my log was showing that the rollback was happening. I've been wrestling with this for a couple days so my setup has changed quite a bit, here's my current setup. Lo...

How to construct these HQL statements

Do anyone know how to construct these two SQL statement in HQL; SELECT MIN(id) FROM Books WHERE mid < ? OR mid =? SELECT SUM(noOfBooks) FROM Bookcount WHERE mId=128 ...

Customizing Hibernate Criteria - Adding conditions to a left join

I need to be able to do the following: Select * from Table1 left join Table2 on id1 = id2 AND i1 = ? Hibernate criteria doesn't allow be to specify the i1 = ? part. The existing code is using hibernate criteria and it would be a huge refactor to swap out for HQL Does anybody have any tips how I could implement this differently or ...

Best approach for Java/Maven/JPA/Hibernate build with multiple database vendor support?

I have an enterprise application that uses a single database, but the application needs to support mysql, oracle, and sql*server as installation options. To try to remain portable we are using JPA annotations with Hibernate as the implementation. We also have a test-bed instance of each database running for development. The app is bui...