hibernate

Is there any tool for automatically generate java classes with annotation style in hibernate?

Hello, I just have the db schema, and want to get the corresponding java classes for them in hibernate, and I do not want the hbm xml file style, so want to get the java classes with annotation generated automatically, is there any tool for this job? Thanks a lot. ...

How do I use mysql compress() / uncompress() with hibernate?

How do I use mysql's compress() and uncompress() functions to compress text before I store it and uncompress it when I retrieve it using a mysql database with hibernate for ORM? ...

Help needed with Spring/Hibernate Lazy-loading

Hi, I know that this has been discussed lot of times. I just can't understand how this work or where my mistake is. I think giving you a reduced example is the best way to show you what I'm trying to do and what assumptions I'm taking... I have a Product class with a name. The name is a String property that is lazy. My DAO: public ab...

Connecting to MS SQL Server 2005 via Hibernate

I have JRE 1.6 and am using the following hibernate.cfg.xml file. I am always getting "Cannot open connection" and "The port number 1433/DB is not valid." <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property> <property name="hibern...

Lost in dates and timezones

I'm working on an application that stores conferences with their start and end date. Up until now, I was developing in Belgium and my server is in France, so everything is in the same timezone, no problem. But today, I'm in San Francisco, my server is in France and I noticed I have a bug. I'm setting dates from a Flex client (ActionScri...

Hibernate Unknown Entity

I have two jar files with hibernate classes mapped. One jar file is perfectly working and for the next jar file it is not mapped. I get Unknown Entity exception. Persistence.xml is good but i dont know why this is happening. Any guess what mite be the issue??? ...

how to pass user created connection to hibernate

hi, is there any way, to restrict hibernate not to create connection of its own(what we define in hibernate.properties or hibernate.cfg.xml), instead i can create and pass the connection to hibernate for further processing. The problem is that i need to set the ApplicationContext on the connection given that the i am using oracle connec...

how to remove the mapping resource property from hibernate.cfg file

hi, i am currently working on one project. In my project there are many entity/POJO files. currently i am using simple hibernate.cfg.xml to add all the mapping files in to the configuration like :- <mapping resource="xml/ClassRoom.hbm.xml"/> <mapping resource="xml/Teacher.hbm.xml"/> <mapping resource="xml/Student.hbm.xml"/> i am havin...

how to implement inheritance in hibernate ??

I have a entities as: BaseEntity --> Which contains user login info like createdBy, createdTime, EditedBy, editedTime Employee --> which contains employee information like name, address, etc... RegularEmployee --> which contains salary, bonus tht kind of fields and ContactEmployee --> which contains HourlyRate, contactPeriod etc.... ...

Rolling back a transaction in a Grails Service

I have been updating all my services to be transactional by using Grail's ability to rollback when a RuntimeException is thrown in the service. I have, in most cases, doing this: def domain = new Domain(field: field) if (!domain.save()) { throw new RuntimeException() } Anyways, I wanted to verify that this indeed will rollback the ...

Cannot instantiate abstract class or interface : problem while persisting

i have a class campaign that maintains a list of AdGroupInterfaces. im going to persist its implementation @Entity @Table(name = "campaigns") public class Campaign implements Serializable,Comparable<Object>,CampaignInterface { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strateg...

How do I prevent unauthorized users from deleting objects in my domain model?

I got similar domain model 1) User. Every user got many cities. @OneToMany(targetEntity=adv.domain.City.class...) 2) City. Every city got many districts @OneToMany(targetEntity=adv.domain.Distinct.class) 3) Distintc My goal is to delete distinct when user press delete button in browser. After that controller get id of distinct and p...

Could not synchronize database state with session

Hello all, I'm having trouble trying to persist an entity which ID is a generated value. This entity (A), at persistence time, has to persist in cascade another entity(B). The relationship within A and B is OneToMany, and the property related in B is part of a composite key. I'm using Eclipse, JBOSS Runtime, JPA/Hibernate Here is my c...

hibernate search

Hi! I am using Hibernate. I am looking for a free text engine. Before I investigate into it I need your experience. I have in my applications user, role and object table. Where a user is connected to one or more roles, and a role is connected to one or more objects. In my free text search, the user can reach only data that he is all...

hibernate search and projection - different fields on different objects

Hi! I have the following code: Criteria crit = sess.createCriteria(Product.class); ProjectionList proList = Projections.projectionList(); proList.add(Projections.property("name")); proList.add(Projections.property("price")); crit.setProjection(proList); But I also have User.class and I would like the name to be restricted on U...

Configuring hibernate.reveng.xml to detect a sequence PK generator with hibernate3-maven-plugin and Postgre

Hi, is there a way to configure hibernate3-maven-plugin so that a sequence generator is detected for a primary-key? I'm using a bottom-up approach for hibernate configuration (which means letting hibernate-tools generate the hibernate configuration using a jdbc-connection for you via reverse-engineering on an existing database schema). ...

How to retrieve the ordered list of best articles having a minimum number of votes by using HQL ?

I have a Vote domain class from my grails application containing properties like article_id and note I want to HQL query the Vote domain class in order to retrieve the 5 best rated articles having at least 10 votes. I tried : SELECT v.article_id, avg(v.note), count(*) FROM vote v where count(*) >= 10 group by v.article_id order by av...

Calculated property with JPA / Hibernate

My Java bean has a childCount property. This property is not mapped to a database column. Instead, it should be calculated by the database with a COUNT() function operating on the join of my Java bean and its children. It would be even better if this property could be calculated on demand / "lazily", but this is not mandatory. In the wo...

JPA/JDO entity to XML XSD generator.

I am using JDO or JPA on GAE plugin in Eclipse. I am using smartgwt datasource, accepting an xsd. I would like to be educated how to generate an XSD from my jdo/jpa entity, vice versa. Is there a tool to do it? While datanucleas does all its magic enhancing in the Eclipse background, would I be able to somehow operate in a mode that w...

How to create an entity with a composite primary key containing a generated value.

Using Hibernate + annotations, I'm trying to do the following: Two entities, Entity1 and Entity2. Entity1 contains a simple generated value primary key. Entity2 primary key is composed by a simple generated value + the id of entity one (with a many to one relationship) Unfortunately, I can't make it work. Here is an excerpt of the ...