hibernate

How can i get only the first level of childrens in Hibernate

If I have this three structure in a table, -A | *---B | | | *---C | | | *---D | | | *---E | | | *---F | | | *---G *---H *---I | *---J assuming list() method is called and it returns a colleccion of B and H. In this scenario I would like hibernate obtain C,D,I an...

Automatic reserved word escaping for Hibernate tables and columns

I am trying to use one Hibernate mapping for several different databases: H2, Oracle, MySql. Each database has a different list of reserved words. I would like Hibernate to automatically escape the reserved words. I know I can: use backticks to force escaping (escape everything just to be safe) change all identifiers so they are ce...

How to pass Java Date object to dojo DateTextBox through Spring MVC and back to Java?

I wonder how can I pass a Java Date object from beans --> hibernate --> Spring MVC --> dojo and back to that Date object that would be stored in the database using hibernate. I have tried, in beans class, creating getter and setter that return/get String by parsing the value to dojo friendly format (yyyy-MM-dd). When the date from the d...

NHibernate CreateSqlQuery and addEntity

The hibernate manual says this: String sql = "SELECT ID as {c.id}, NAME as {c.name}, " + "BIRTHDATE as {c.birthDate}, MOTHER_ID as {c.mother}, {mother.*} " + "FROM CAT_LOG c, CAT_LOG m WHERE {c.mother} = c.ID"; List loggedCats = sess.createSQLQuery(sql) .addEntity("cat", Cat.class) .addEntity("mother", Cat.class).l...

Hibernate: Updates all the items of a set - Cascade 'create' not working

Hi All, I am using following data model (changed to make it simpler). Table: STUDENT, TEACHER, BOOKS_ASSOCIATION, BOOKS_DETAILS. Student and Teacher have a column whose forign key is BOOKS_ASSC_ID, hbm mapping as following <many-to-one name="bookAssociation" class="com.example.BookAssociation" not-null="false" fetch="join" cas...

Wicket + Spring + JPA + Hibernate tutorial

Hi, I'm looking for a step by step tutorial on building small web application using Wicket, Spring, JPA and Hibernate assuming that the programmer is advanced in java but new to those technologies (so if the whole set up was included that would be perfect). Could anyone help? Thanks in advance. ...

To catch the reason of the unique constraint on JPA

Hello everyone. I am trying to learn JPA and I have a problem that I stucked in since 2 days. I have a table named "User" includes id,email,password,username and status. As you guess email and username columns are unique. I also have a Class called User something like that : @Entity @Table(name = "user", uniqueConstraints = @UniqueC...

hibernate bidirectional one-to-many inserts duplicates

Hello everyone. I'm having issues with a parent-child relationship here. When I persist from the collection side (child side) I get 2 new children instead of one. Here is are the hibernate mappings: <set name="children" inverse="true" cascade="all,delete-orphan" lazy="true" order-by="CHILD_ID desc"> <key...

Can I select null as a column value in HQL query?

I need a list with three columns. column 1st and 3rd having values while 2nd as null. Can I do it through HQL query? I need something like this: select id, null, name from MyClass Where MyClass as well as underlying table has only two properties/columns ie, "id" and "name" ...

Struts2 Hibernate (returning a list causing hibernate to fetch data from all relationships)

Hello, I am creating dependent drop downs using Struts2 jquery. The problem is that getLobList() method inside action class is causing hibernate to fetch all data for a lob. If I remove that getter method, those logs are not created. Why is this happening any way to fix it? JSP page <s:url id="remoteurl" action="getLists"/> <sj:select...

Many-to-many relationship on the same entity without additional join table columns

I have an entity that has many-to-many association to itself. If I needed some additional properties (like asked here) the answer would be to use a new intermediate entity. But without them is it bad practice to use direct many-to-many association to the entity itself? ...

What is a good inheritance strategy with Hibernate and JPA?

Hi all, i have this situation: I have an entity, "Person", that contains all personal details of a person, like birth date, street address, municipality ecc ecc. And i have an entity "ClubMember" that describe a member of a club and contains some field like: registration date, type of member, credit, ecc ecc So, a ClubMember is a Perso...

(hibernate) table altered after failed commit

I'm new to hibernate. I have a transaction that fails with a HibernateException, yet the table is altered after the commit. Here is the code: public StoreResult store(Entry entry) { Session session = HibernateUtility.getSessionFactory().openSession(); Transaction transaction = session.beginTransaction(); try { ...

Can I create both MyISAM and InnoDB tables in the same database using Hibenrate hbm2ddl

I need both MyISAM tables and InnoDB tables in my database, I am using hbm2ddl to create them. Can I create both MyISAM and InnoDB tables in the same database using Hibenrate hbm2ddl? It seems that selecting the dialect forces me to use one or the other. ...

Why hibernate perform two queries for eager load a @OneToOne bidirectional association?

Hi, i have entity A that has-a B entity, and B has-a A with @OneToOne bidirectional association. Now, when i findall A records, hibernate perform two queries with a left outer join on B, something like this: select a.id, a.id_b, a.field1, b.id, b.field1 from A as a, B as b left outer join b ON b.id=a.id_b; select a.id, a.id_b, a.field1...

any third party free Java library that can calculate grades based upon marks of student ?

Hi i am making a school information software. Is there any third party reliable library that can be used for calculating grades of students referring marks for the same from specified database.It should be flexible enough to let client specify criteria for grade calculation in terms of standard deviation, median etc. ...

JPA 2.0 Criteria and grouping of Predicates

I encounter problem with Hibernate EntityManager 3.5.3-Final when it comes to composite predicates. Example (not actual code snippet, but the idea should be clear): CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); Predicate predicate1 = criteriaBuilder.conjunction(); Predicate predicate2 = criteriaBuilder.conjuncti...

Hibernate JPA, MySQL and TinyInt(1) for Boolean instead of bit or char

Hi Here is my JPA2 / Hibernate definition: Code: @Column(nullable = false) private boolean enabled; In MySql this column is resolved to a bit(1) datatype - which does not work for me. For legacy issues I need to map the boolean to a tinyint not to a bit. But I do not see a possibility to change the default datatype. Is there any? ...

The application requester cannot establish the connection. (Too many open files)

I develop application run in Websphere work manager. work manager is used to run thread in the webpshere applications erver. Every 5 minutes my thread try to get some data from MySQL database from the different host from the application server machine. When the Host of MySql database turned off, The work manager always try to connect t...

hibernate dao design question

Im looking to create a generic DAO to handle CRUD in my hibernate app. My entities have most associations as LAZY fetching. But I find in order to have hibernate be efficient as possible with the SELECTs I have to create multiple methods on my DAOs. Here's what I mean: Entity A has two associations. Sometimes I want to retrieve this...