hibernate

concurrency in hibernate

I have a servlet that does some work for user and then decrement user's credit. When I watch user's credit in the database in real time, if there are many concurrent requests from the same user, the credit has been deducted incorrectly due to concurrency control. T Assume I have one server and database management used is hibernate. I am...

Java Hibernate Memory leak

Hello, I'm developing a Flex application with BlazeDS and I'm experiencing memory leak when using java to query from MySQL in hibernate. Can anyone tell me how to deal with this memory leak? It seems that each time query is invoke java.exe takes more memory. Thanks Sample of my java factory = Persistence.createEntityManagerFactory(PE...

how to map a one-to-many collection to a joined subclass when key is in the parent class

I'd like to map a one to many collection to a subclass but the key of the collection is an attribute of the parent class. Currently i'm mapping AbstractFoo Foo and Bar class like this : <class name="AbstractFoo" abstract="true" table="abstractFoo"> <id name="_id" column="foo_pk"> <generator class="native" /> </id> <many-to-on...

How do I persist a Java property of type Object using Hibernate?

I have a Java class with a property like this private Object myObj; When I try to save the class using Hibernate annotations, I get the rather confusing error message "property mapping has wrong number of columns". What is the correct approach to persisting a class containing a generic property such as this? ...

SQL argument limit in Oracle

It appears that there is a limit of 1000 arguments in an Oracle SQL. I ran into this when generating queries such as.... select * from orders where user_id IN(large list of ids over 1000) My workaround is to create a temporary table, insert the user ids into that first instead of issuing a query via JDBC that has a giant list of para...

Not so simple Hibernate question

Hey people, i have a the following map* which is giving me lots of trouble: Map<MetricSourceInterface, AliasesInterface> MetricSourceInterface is an entity with simple properties. AliasesInterface is an entity with only an Id and a list of strings. Hibernate is creating the database schema so theres no problem with changing it whatso...

Postgresql OutOfMemory with Criteria.scroll() in Hibernate with 2M records

I am running a Criteria.scroll() on PostgreSQL on a DB containing 2M records. The memory keeps increasing and finally it generates an OutOfMemoryException. Please can you advice how to fix this. Postgresql DB version: 8.4 Postgresql Driver Used: postgresql-8.4-701.jdbc4.jar Is there some known issue with Hibernate scroll() in Pos...

Hibernate database specific columnDefinition values

Hello, the problem is as follows: We're using hibernate with annotations as O/R Mapper. Some @Column annotations look like: @Column(columnDefinition = "longblob", name = "binaryData", nullable = true) or @Column(columnDefinition = "mediumtext", name = "remark", nullable = true) with the columnDefinition attributes being mysql speci...

Query on hibernate entity with user-type field

Hey, working with JPA above hibernate impl. I map my enums by using user-type follow the good practice to store a persistence key to the enum and not the ordinal (which can be changed). Now, i have a problem to query on the enum field. it seems that hibernate dont execute the user type convert on the name-query. Any idea? ...

H2 database In memory - Init schema via Spring/Hibernate

I have a Spring/Hibernate application with H2 database and I have a few issues with configuring H2 to run in an embedded mode (in memory): 1. I want spring to start the H2 database so I created the following Spring beans: <bean id="org.h2.tools.Server" class="org.h2.tools.Server" factory-method="createTcpServer" init-method="sta...

Implementing a data history / versioning solution for a Hibernate-based application (with a twist).

First the basic facts: Java webapp, Spring, Hibernate, MySQL. The situation is that I have a complex object model of e.g. a Car. It's composed of many objects (Engine, Tires, ...) with many-to-one and one-to-many relationships between them. Now there are many cars, and every now and then someone inspects a car and creates a Report of...

How to map the type Interval in Hibernate ?

Hi, under PostGresql, Im using PersistentDuration for the mapping between the sql type interval & duration but it doesnt work. An other user found the same issue & come with his own class: public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException { if (value == n...

Hassle with Hibernate and Spring and Dynamic Proxies

Hi, I would like to implement something like a PDO pattern in conjunction with Spring. All domain objects are implemented according to their interface. Each domain object implementation also has an autowired DAO implementation to be able to directly persist the object. (e.g. foo.persist()). This works pretty well, Spring also inserts th...

Case Sensitivity and Indices in MYSQL

I am creating a system where is use e-mail address as unique identifier. There are times I need to look for a user by the e-mail address. If the user enters the e-mail address in all lower case, but the database has it stored as mixed case, is it a full scan, or will the database still use the index? This really is a problem because I ...

EntityManager fails to instantiate using JPA/Hibernate when I add a OneToMany annotation

I have been struggling with not being able to have the EntityManager be instantiated when I add a OneToMany column to a class that already has a OneToMany column. Right now the EducationInfo has a OneToOne to user, since each row will be unique to a person, but I want to be able to load all the education information given a username. I...

spring - hibernate load *.hbm.xml from classpath resource

I have some hbm.xml files in classpath resource located in src/main/resources maven's folder. I used spring's LocalSessionFactoryBean to load these files with the following bean config: <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSourceOracl...

Hibernate NullPointerException In Loader Class

I'm having a bit of an odd problem. This is Hibernate 3.3.2-GA with DB2400Dialect. I'm seeing the following exception -- java.lang.NullPointerException at org.hibernate.loader.Loader.doQuery(Loader.java:720) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loa...

hibernate - session monitor tool

please tell me is there anytool to monitor hibernate sessions in case of session leakage Thank you. ...

Is learning Java and related technologies worth it today?

My career has always been C and C++ programming. I have some basic Java experience. I have a lot of personal Ruby/Rails experience and lately I've been doing some Grails stuff at work as well. I'm just curious if it's worth it to pick up Java and related technologies such as Spring, Hibernate, etc... Grails seems like it removes the n...

cannot get clob datatype from database into JPA entity

I able to save (spring-hibernate saveorupdate()) field @Lob @Column(name = "FILENAME") private String filename; into oracle database datatype is clob but when i try retrieve it, i get error ERROR - JDBCExceptionReporter.logExceptions(72) | ORA-00932: inconsistent datatypes: expected - got CLOB below is how i retrive ...