hibernate

Ant task for generating ER diagram from JPA/Hibernate annotated classes

Does anyone know of a tool that can do that? Linguine maps seems to only work on old hibernate xml files. And the hibernate tool task hbm2hbmxml seems to have a bug so that I can't do the two step process "annotations->hbmxml->diagram" Best, Anders ...

How to map a set of objects in Hibernate without primary keys being equally named?

I have a domain object class that represents a table. This class has an association to another table, but the source class' property is not named the same as the target class' property, and I'm not sure how to hibernate map it. Here is an example of the class to have the set (one CT to many R instances): public class CT { // This ...

Hibernate Annotation Join table question

Hi there, When doing join table with hibernate annotation, how to i add an extra column that's not a join column, like, say married as a weak entity? like an extra column? @ManyToMany(targetEntity=some.class, cascade ={CascadeType.PERSIST, CascadeType.MERGE}, fetch=FetchType.EAGER) @JoinTable(name = "RELATION", joinColumns ={ ...

what the heck is a JPA configuration?

I'm going nuts trying to get a simple Envers example to work. I'm stuck on the org.hibernate.tool.ant.EnversHibernateToolTask it looks like I finally got all the jar files I needed, but now I get the error message [hibernatetool] Persistence unit not found: 'ConsolePU'. BUILD FAILED C:\deka\proj\java\test-database\build.xml:61: Persi...

Why size of lucene index increased if i index the same data?

I implemented Hibernate search in my application i.e. based on Lucene. Whenever, i indexes the database, the size of the lucene indexes increase. But, the result of the query return same no of results every time. Why the size of lucene increases each time if i index the same data everytime? FullTextSession fullTextSession = Search.get...

Hibernate ordering

I have the Vehicles class and mapping file for it and i want to get all rows from vehicles table ordered by ID desc (I also need the same for my other tables). I got the following code: session = HibernateUtil.getSessionFactory().getCurrentSession(); tx = session.beginTransaction(); q = session.createQuery("from Vehicles order by ID D...

MySql in WinXP and Mac OS X

Hello Folks, I am facing this bizarre problem. I am coding on my machine in Win XP and then moving all the code to Mac OS X machine. Running it using the jars from XP machine. I am coding in java and using hibernate for database processing. Somehow I am not able to insert one row, while the keys are generated using the increment ge...

Hibernate query (not SQL) logging

I'm using Hibernate's EntityManager as a JPA implementation. What I want is logging of the query (HQL or JPA Query Language) made to EntityManager. This is different than SQL logging (which is enabled with the hibernate.show_sql property). My application issues several queries to Hibernate. I want logging of both the queries issued to H...

Hibernate set mapped to a 'sql select' table

Good day, I have a hibernate mapping which goes something like this <class name="Person"> <id name="id" type="long" column="person_id" unsaved-value="null"> <generator class="sequence"> <param name="sequence">person_id_seq</param> </generator> </id> ... <set name="thinCollection" table="(select perso...

A class that behaves like @Entity and @Embeddable

Hi, I have a one way @OneToMany relationship between a Team and Player class. I would like to save a Team object among your Players. Player's identifier IS COMPOUND by Team foreign key and list index as follows. I have a mapping like this one because i need to save Team and your Players ate the same time. @Entity public class Team { ...

Is my DAO strategy ok?

I'm using Hibernate. The question is at the bottom. The current strategy It's simple. First of all, I have a basic Dao<T>. public class Dao<T> { private Class<T> persistentClass; private Session session; public Dao(Class<T> persistentClass) { this.persistenClass = persistentClass; this.session = Hibernate...

Hibernate not creating entity tables if embedding components

I have made an application using Java/Hibernate/MySQL, but whenever I try running it, it complains that the table for one of my entity classes has not been created. After some trial and error, I have come to the conclusion that the problem is coming from the way I am mapping embedded components, but I do not know how I may fix it. Here...

How to use hibernate interceptors to populate extra fields in a join table?

I have a legacy object model that has content objects and a table designed to express relationships between content objects. The latter is called a content_content_connections table, and in addition to having the primary key of the from and to content, it also contains 3 other fields. A connection type field, and content type id fields...

How to keep Hibernate mapping use under control as requirements grow

I've worked on a number of Java web apps where persistence is via Hibernate, and we start off with some central class (e.g. an insurance application) without any time being spent considering how to break things up into manageable chunks. Over time as features are added we add more mappings (rates, clients, addresses, etc.) and then amoun...

hibernate multiple databases

Hi, What is the best way to support multiple databases using hibernate? I see the following article... https://www.hibernate.org/429.html It seems Shards is a possible solution, though the con mentioned is that it's not appropriate for large numbers of schemas. My requirement, is that we have many different databases, multiple databa...

JSF, Hibernate

Hi, I have a table called Items. When I tried to do 'Hibernate Reverse Enginering' in MyEclipse and run the program, I got this error: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?tems0_.ItemID...

What is the proper JPA mapping for @Id in parent and unique sequence in base classes

I have a class hierarchy: abstract DomainObject { ... @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="SEQ") @SequenceGenerator(name="SEQ",sequenceName="SEQ_DB_NAME") @Column(name = "id", updatable = false, nullable = false) private Long id; ... } BaseClass extends DomainObject { ... // Fill in ...

difficulties getting a simple envers example to work: problem #34

I'm trying to get a simple envers example to work. I have the Java code working (apparently), and I finally got the org.hibernate.tool.ant.EnversHibernateToolTask to work, but it only outputs SQL for the "regular" data, not the versioning data. I'm stumped for what to do next. What might I be forgetting to include? Here is the SQL it o...

proper DAO way to do a 'save if not in the db'?

Here's what I have, which has problems: public User addUser(final String name, final String uid) { final List<User> result = findByProperty("uid", uid); if (!result.isEmpty()) return (result.get(0)); final User user = new User(name, uid); saveOrUpdate(user); return (user); } where findByProperty is usin...

How to perform date operations in hibernate HQL

Hello friends, I want to perform data time operations using hibernate hql. I want to add and subtract two dates as well as I want to subtract 1 year or 1 month from a particular date. How is this possible using HQL in hibernate. Does anyone know about it? is there any tutorial available for this? Please help if you can. Thanks. ...