hibernate

Hibernate Criteria API - adding a criterion: string should be in collection

I have to following entity object @Entity public class Foobar { ... private List<String> uuids; ... } Now I'd like to make a criteria query which would fetch all Foobar pojos whose uuids list contains the string "abc123", I'm just not sure how to make the appropriate criterion. ...

How to check for case sensitive in hibernate criteria

0 vote down star I have used hibernate to fetch the login information from the mysql database. But the problem is that say for example the user name is 'dhiraj' in the database, now the login is successful by entering the user name, but it is also allowing to enter by taking the user name in uppercase also, e.g., 'DHIRAJ'. I want to r...

jersey restful + grizzly server + hibernate

I can bring jersey + grizzly server up. But some problem occur during "SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory;" error says "SEVERE: service exception: org.hibernate.HibernateException: /hibernate.cfg.xml not found .. anyone know how to make hibernate can access hibernate.cfg.xml location. ...

How can I get the Hibernate Configuration object from Spring?

Hi, I am trying to obtain Spring-defined Hibernate Configuration and SessionFactory objects in my non-Spring code. The following is the definition in my applicationContext.xml file: Code: <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="hibernateProperties"> <props> ...

LazyInitializationException in Spring

Hello, I'm getting a LazyInitializationException in my Spring Application. I have the OpenEntityManagerInViewFilter configured so I have all my relations set as FetchType.LAZY and they all work. The problem is when I try to access the user which is in session via Spring Security and print LAZY information in the JSP, something like this...

Partioning with Hibernate

Hello, We have a requirement to delete data in the range of 200K from database everyday. Our application is Java/JEE based using Oracle DB and Hibernate ORM tool. We explored various options like Hibernate batch processing Stored procedure Database partitioning Our DBA suggests database partitioning is the best way to go, so we can...

How to set up default schema name in JPA configuration?

I found that in hibernate config file we could set up parameter hibernate.default_schema: <hibernate-configuration> <session-factory> ... <property name="hibernate.default_schema">myschema</property> ... </session-factory> </hibernate-configuration> Now I'm using JPA and I want to do the same. Otherwise I have...

How to set a limit to inner query in Hibernate?

I have HQL like this: from Table1 t1 where t1.name not in (select t2.name from Table2 t2 order by t2.date limit 10) The problem is it doesn't understand limit keyword. Is there a way to run such query without splitting it into two subqueries? ...

HQL Insert Query in Grails

I want to write an insert query in Grails. I have tried all possible combinations but cant get the syntax correct. Can anybody please help? class Person { int age String name } i tried the following: Person.executeUpdate("insert into Person values (20,"ABC")") p.s.:Please do not mention using save() ...

Hibernate Bi- Directional many to many mapping advice!

hi all, i woundered if anyone might be able to help me out. I am trying to work out what to google for (or any other ideas!!) basically i have a bidirectional many to many mapping between a user entity and a club entity (via a join table called userClubs) I now want to include a column in userClubs that represents the role so that when ...

Hibernate: Programmatically binding UserType's on Components

I have several different UserType's (org.hibernate.usertype.UserType) in the system. For this question I will focus on the fact that we use Joda time DateTime and its UserType, PersistentDateTime. I have successfully bound the UserType programmatically to PersistentClass's by: public void customize(Ejb3Configuration config) { Iterato...

How to use an external file for database configuration in EJB environment

I need to have a file for database configuration outside of EAR file of my EJB application. Even if I define a datasource and call it via JNDI, I still have some properties that I want to change, like hibernate.dialect or hibernate.show_sql, for example. I tried using: <property name="hibernate.ejb.cfgfile" value="some-file.xml" /> an...

How to do multiple column UniqueConstraint in hbm?

Working on some legacy hibernate code. How do I do the following with hbm.xml(hibernate mapping file) instead of with annotations? @Table(name="users", uniqueConstraints = { @UniqueConstraint(columnNames={"username", "client"}), @UniqueConstraint(columnNames={"email", "client"}) }) public class User implements Serializable { ...

JPA @TableGenerator shared between multiple entities

Hi Guys, I have a 'dog' Entitiy with an @Id and a @TableGenerator ... @TableGenerator(table = "seq", name = "dog_gen", pkColumnName = "seq_name", valueColumnName="seq_val") @Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "dog_gen") private Long id; ... Is there a way to reuse the same table generator (dog_gen) in othe...

Different cache concurrent strategies for root entity and its collection (Hibernate with EHCache)?

Given example from Hibernate docs and modifying it so that root level entity (Customer) is read-only while one of its collections (tickets) is read-write: @Entity @Cache(usage = CacheConcurrencyStrategy.READ_ONLY) public class Customer { ... @OneToMany(...) @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public Sor...

hibernate formula with column

I have a table with a column that will be encrypted by a trigger after the record is inserted. When I read the column, I need to apply a decrypt function in the hibernate domain class. While saving the object, the value of the column will be saved as such. While reading the column, apply a database function on the read data. @Formula an...

Hibernate - Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1

Hi All, I get following hibernate error. I am able to identify the function which causes the issue. Unfortunately there are several DB calls in the function. I am unable to find the line which causes the issue since hibernate flush the session at the end of the transaction. The below mentioned hibernate error looks like a general error. ...

Hiberate variable schema name in SQL named query

Hi, Other than default schema, for some SQL queries I need to access a particular schema. The issue is that the name of that particular schema is different for different environments. After goggling I found that using this link I am able to specify the schema name in variable. If that’s true that I have following questions: Will that...

How to configure Hibernate database reverse engineering tool to map database table relation as a entites inheritance?

Is it possible to configure Hibernate reverse engineering and code generation tool in such a way that one-to-many relation between tables is mapped to entities inheritance instead of enrites relation? I have Person table and Employee table, which are related with the foreign key (Person contains basic information, Employee the rest). In...

em.persist seems doesn't persist data on postgreSQL db

I've got a simple java main which must write bean data on a PostgreSQL database. I use Entity manager to persist or update object. I use hibernate and toplink driver connection which are specified in persistence.xml file. When I call em.persist(obj), nothing is saved on database, I don't know why. here is my simple code: private static...