hibernate

IntelliJ IDEA with hibernate support

I have IntelliJ IDEA 8.1.3. It has support for a hibernate facet/plugin which I have enabled. When I do this it recognises the HQL query strings but highlights in red all the objects and properties. I can't see how to get IDEA to be aware of my entities. I use spring+hibernate and annotated objects. I have no hibernate.cfg.xml just ...

Hibernate creates too many connections using @Transactional, how to prevent this?

Hello there, I'm fairly new to Hibernate and PostgreSQL, but so far it's going well, although I'm running into a problem now that I can't solve. I'm getting an error while filling the database on the very first operation (which is one transaction inserting or updating 1000 rows in the database). The error is: SQL Error: 0, SQLState: ...

Spring, JPA (Hibernate) & Ehcache Poor Performance

Hi folks, I have what I would assume is a pretty standard setup...spring, jpa (hibernate) and I'm trying to add ehcache. I have it all configured and verified that it's working...I'm logging the hibernate sql statements and cache statements and can see that the cache is getting invoked and that once the object is in the cache, when I t...

jboss5 class loader problem with spring and hibernate trying to parse applicationContext.xml

I am using Jboss5 and I'm trying to utilize Hibernate and Spring to load in a spring dao. I'm getting an exception which seems to point to an incompatibility in jars but I'm not quite sure what is going on. I've done quite a bit of searching and I can't seem to find something specific to this besides change JBOSS versions. I am wanting t...

JPA & DDD: how to implement side effects of entity deletes and inserts

I am building an application under DDD architecture, thus I have implemented rich domain objects that can also be entities. These entities can also have full access to (injected) repositories that can do add & remove operations on other objects/entities. So far, this all works without any problems. But can side effects for objects/entit...

How to use database as backup/failover in hibernate?

Hi, My application is based on the hibernate to fetched data from a mysql server. This mysql server is replicated to another mysql server instance. Today, I got a downtime as the primary database server was gone down without any notice. To avoid any future accidental problem, I am planing to add a functionality that will enable system t...

org.hibernate.MappingException: Unknown entity

I'm trying to work through Beginning Hibernate 2nd edition, and I'm stuck trying to put together the simple working example with HSQLDB. When I run ant populateMessages, I get [java] org.hibernate.MappingException: Unknown entity: sample.entity.Message [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194...

Hibernate v3.6 : Issue with the EntityManager method "refresh"

Hello, The following code throws an exception when invoking "em.refresh(p)": 1: EntityManager em = emf.createEntityManager(); 2: em.getTransaction().begin(); 3: 4: Product p = new Product("J&D", 35.0,"Whisky"); 5: em.persist(p); 6: 7: em.refresh(p); 8: em.getTransaction().commit(); 9: em.close(); When debugging the code, we see that ...

How to map Memory(HEAP) MySql table in Hibernate xml file?

Just example of xml file will be enough) OR Can Hibernate load needed entity(all records) at the starting of application and store it in memory for quick access? ...

Hibernate: Add a property in my class that is not mapped to a db-table

I have a table tbl_sky that has 2 properties name and model and I would use Hibernate annotation like; @Entity @Table(name="tbl_sky") public class Sky implements Serializable { private String name; private String model; private String status; @Id public String getName() { return name; } . . . But I nee...

Best way to debug MySQL connections that are being closed on me after ~39 minutes?

I have hibernate 3.3, c3p0, MySql 5.1, and Spring. The MySQL connections in my service calls are consistently being closed after ~39 minutes. The natural running time of my service call is on the order of ~5 hours. I've tried changing various c3p0 config, etc, to avoid the 39 minute cap. No luck. Is there a more direct, systematic wa...

JPA/HIBERNATE - Are objects instances cached indexed just by id ?

Probably it is a basic question, but could not found the answer anywhere in the web. I am trying to use a second level cache (using ehcache) and just checked that some objects were being retrieved from database every time I tried to load them, the only difference was that I was not getting them by id but by a property that carries a SE...

Why should we stop using Ibatis and start using Hibernate?

Preparing a proposal for my team, I have the obvious ones. Ibatis is retired, no more fixes/enhancements. Hibernate is the de-factor standard. Hibernate has more/better documentation. What would add or take away from the proposal? Thanks ...

What is the significance of the number 117 for hibernate?

It is gone now, but for a long time the "advanced problems" page at the hibernate website was: http://www.hibernate.org/117.html Why was it 117.html? Was there some sort of significance to this particular number? ...

mappedBy reference an unknown target entity property

I am having an issue in setting up a one to many relationship in my annotated object. I have the following: @MappedSuperclass public abstract class MappedModel { @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="id",nullable=false,unique=true) private Long mId; then this @Entity @Table(name="customer") ...

changes to the schema while hibernate is running

Hi all, I'm working on a high usage system which maps a few "read only" tables and views. At various points in time I need to replace the data in these tables with a newer version by connecting to the database externally. We are using postgres 8.3+ and hibernate 3.2.6. The external "update" process will be connecting to the db via PSQL...

Hibernate Execption

i want to try to find out all the fieldValue based on fieldName MNC.java: `private Map <String, String>formFields = new HashMap<String, String>(); public void setFieldValue(String fieldName, String fieldValue) { if (formFields == null) { formFields = new HashMap<String, String>(); } formFields.put(f...

Hibernate using multiple databases

I need to have multiple databases for different customers. How can I handle multiple databases with Hibernate? Are there any good examples how to do this? I could create Configuration object and then build SessionFactory, but that would create always a new session factory which wouldn't be very wise. EDIT: Now I can get hibernate Conf...

Grails: domain class mapping (collection of hibernate user types)

Hello, I am wondering if is possible to implement following domain model. Let's have a domain class which contains set of intervals (joda time). I can use org.joda.time.contrib.hibernate.PersistentInterval hibernate user type for mapping of Interval to database table (by similar way as in http://www.grails.org/JodaTime+Plugin). However...

How to make sure changes in the database that happen within a transaction are also seen by everything within that transaction

I've got a transaction that saves or updates a set of objects in a database. This is the code: @Transactional public void updatePDBEntry(Set<PDBEntry> pdbEntrySet) { for (PDBEntry pdbEntry : pdbEntrySet) { PDBEntry existingEntry = findByAccessionCode(pdbEntry.getAccessionCode()); if (existingEntry != null) { ...