hibernate

Why do Unicode characters show up properly in database, but as ? when printed in Java via Hibernate?

I'm writing a webapp, and interfacing with MySQL using Hibernate 3.5. Using "デスクトップ ინგლისური" as my test string, I can input the string and see that it is properly persisted into the database. However, when I later pull the value out of the database and print to the console as a String, I see "?????? ?????????". If I use new OutputS...

Anything similar to Hibernate in PHP?

I am a Java programmer and was working on a project using Hibernate and Struts for some time. Now For my new project, I am working on PHP and Mysql (learning PHP). Is there any technology which is similar to Hibernate for PHP? If yes, can anyone give me the link where I can understand and use it? Is there a POJO concept in PHP? ...

Using sql column names in hibernate createSQlquery result

Hi all, i have a couple of sql views with composite primary keys that i want to query, and since Hibernate makes it a pain to work with composite keyes, im using createSQLQuery. The problem is that this method can only return a List, and i need to refer to the colums by their index. Any chance i could do like jdbc and refer to the col...

Spring, Hibernate, Blob lazy loading

Dear Sirs, I need help with lazy blob loading in Hibernate. I have in my web application these servers and frameworks: MySQL, Tomcat, Spring and Hibernate. The part of database config. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="user" value="${jdbc.username}"/> ...

Hibernate save() and transaction rollback

Hi, In Hibernate when i save() an object in a transaction, and then i rollback it, the saved object still remains in the DB. It's strange because this issue doesn't happen with the update() or delete() method, just with save(). Here is the code i'm using: DbEntity dbEntity = getDbEntity(); HibernateUtil.beginTransaction(); Session sessi...

How to reserve a set of primary key identifiers for preloading bootstrap data

We would like to reserve a set of primary key identifiers for all tables (e.g. 1-1000) so that we can bootstrap the system with pre-loaded system data. All our JPA entity classes have the following definition for the primary key. @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "id", unique = true, nullable = false, insertable =...

Hibernate schema parameter doesn't work in @SequenceGenerator annotation

I have the following code: @Entity @Table(name = "my_table", schema = "my_schema") @SequenceGenerator(name = "my_table_id_seq", sequenceName = "my_table_id_seq", schema = "my_schema") public class MyClass { @Id @GeneratedValue(generator = "my_table_id_seq", strategy = GenerationType.SEQUE...

Use Hibernate and Ibatis in the same application

I need to write a new app but using some data acces logic from other two app. One uses Hibernate and the other uses iBATIS. Can I use in the same app both, Hibernate and iBATIS?. How?. Update: Let me reformule my question. Let's forget I will rehuse some DAOs or domain clases. I need to use in the same app, Hibernate and iBATIS. How can...

Eager/Lazy loaded member always empty with JPA one-to-many relationship

I have two entities, a User and Role with a one-to-many relationship from user to role. Here's what the tables look like: mysql> select * from User; +----+-------+----------+ | id | name | password | +----+-------+----------+ | 1 | admin | admin | +----+-------+----------+ 1 row in set (0.00 sec) mysql> select * from Role; +----+...

Hibernate MappingException

I'm getting this Hibernate error: org.hibernate.MappingException: Could not determine type for: a.b.c.Results$BusinessDate, for columns: [org.hibernate.mapping.Column(businessDate)] The class is below. Does anyone know why I'm getting this error?? @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "busines...

Cannot enlist Synchronization. LocalTransactionCoordinator is completing or completed issue with hibernate spring transaction.

I am getting Cannot enlist Synchronization. LocalTransactionCoordinator is completing or completed exception when integrating my method is called from the portlet. I am using spring transaction management for handling all the hibernate transaction in the spring configuration file through AOP. When I run my hibernate dao method for pers...

@OneToMany and composite primary keys?

Hi, I'm using Hibernate with annotations (in spring), and I have an object which has an ordered, many-to-one relationship which a child object which has a composite primary key, one component of which is a foreign key back to the id of the parent object. The structure looks something like this: +=============+ +=======...

About Data Objects and DAO Design when using Hibernate

I'm hesitating between two designs of a database project using Hibernate. Design #1. (1) Create a general data provider interface, including a set of DAO interfaces and general data container classes. It hides the underneath implementation. A data provider implementation could access data in database, or an XML file, or a service, or s...

Ternary (and n-ary) relationships in Hibernate

Q 1) How can we model a ternary relationship using Hibernate? For example, how can we model the ternary relationship presented here using Hibernate (or JPA)? NOTE: I know that JPA 2 has added some constructs for building ternary relationships using maps. However, this question assumes JPA 1 or Hibernate 3.3.x and I don't like to use map...

Java-Hibernate: How can I translate these tables to hibernate annotations?

I need to create a simple application using these tables: http://stackoverflow.com/questions/2612848/are-these-tables-respect-the-3nf-database-normalization I have created the application using simple old JDBC, but I would like to see how the application would look like using Hibernate, but I don't know how to put the sql code in java. ...

Ordering the results of a Hibernate Criteria query by using information of the child entities of the asked entities

I have got two entities Person and Book. Only one instance of a specific book is stored to the system (When a book is added, application checks if that book is already found before adding a new row to the database). Relevant source code of the entities is can be found below: @Entity @Table(name="persons") @SequenceGenerator(name="id_seq...

Delete element from Set

Hi. I have 2 classes Tema(Homework) and Disciplina (course), where a Course has a Set of homeworks. In Hibernate i have mapped this to a one-to-many associations like this: <class name="model.Disciplina" table="devgar_scoala.discipline" > <id name="id" > <generator class="increment"/> </id> <set name="listaTeme" table="devgar_sc...

Hibernates generates VARBINARY column with JPA @Enumerated annotation

Hibernates is generating a VARBINARY column with JPA @Enumerated annotation. I'm using SQL Server 2005 w/ JTDS driver. The mapping is dirt simple: @Basic @Enumerated(EnumType.ORDINAL) private MyEnum foo; I would have expected Hibernate to generate an integer column? I've also tried EnumType.STRING (expecting a varchar column) with no ...

Self-reference entity in Hibernate

Hi guys, I have an Action entity, that can have other Action objects as child in a bidirectional one-to-many relationship. The problem is that Hibernate outputs the following exception: "Repeated column in mapping for collection: DbAction.childs column: actionId" Below the code of the mapping: <?xml version="1.0"?> <!DOCTYPE hiberna...

Issue in Adding data into database using hibernate

Hi , I am getting the following exception while adding data into database: org.hibernate.HibernateException: The database returned no natively generated identity value I am using the following code: Session session = HibernateUtil.getSession(); Transaction tx = session.beginTransaction(); session.save(user); logger.info("Successfull...