hibernate

HIbernate - HBM.xml Automatic generation from DB Schema

Is there any plugin available for Eclipse or Netbeans or any other IDE which can help me generate the hbm.xml by directly reading the schema from the database. Writing those XMLs seem to be unnecessary waste of time, and feel it should be automated. ...

Cannot save clob data type in database (Struts, Spring, Hibernate)

@Column(name="transpired") @Lob private String transpired; public String getTranspired() { return transpired; } public void setTranspired(String transpired) { this.transpired = transpired; } I tried using the following code in our model class. Transpired is a field with long text messages (reports). When viewing the "report", i...

queries with hibernate

I have a database include eventType and event Tables eventType - id - name event - id - name - location - eventType_id - eventSubType_id where eventType_id and eventTypeSubtype_id reference to eventType Table. What i want to do with hibernate is select all events that have : eventType in (2,6) and eventSubType i...

Add new Entity to persisted Collection

I've got to Tables related in one-to-many association: Product*1 - n*Inventory @Entity public class Product { // Identifier and properties ... @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) public Set<Inventory> getInventories() { return inventories; } public void setInventories(Set<Inven...

hibernate: foreign key is primary key

i have 2 tables relation one-to-one: **message**(id, name, content) **scheduled_message**(message_id, start_time, stop_time) i use message_id as primary key of scheduled_message table. my domain class: public class Message { private Integer id; private String name; private String content; ... } public class Schedu...

Controlling Hibernate's generated subselect

Consider the following three Hibernate entities: public class Car { @OneToMany(fetch = FetchType.LAZY) @Fetch(FetchMode.SUBSELECT) private List<Wheel> wheels; } public class Wheel { @OneToOne(fetch = FetchType.LAZY) private Hubcap hubcap; } public class Hubcap { } Consider the following Criteria: Criteria criteria = ...

How to validate Hibernate mapping against database

How to check that Hibernate mapping configuration matches database? I'd like know if I am using wrong version of hibernate mapping before I start executing update and queries, which then would fail. I have bunch of classes that have been mapped with Hibernate annotations. I also have connection to corresponding database. Now I'd like to...

Are there any Java-based web frameworks that are multitenant aware?

Looking for something between simply downloading struts and bolting on vs full-fledged portal software such as Liferay or BEA Portal. Would be great if the database connectivity supported EAV models but allowed developers to think in traditional relational 3NF terms. ...

Hibernate: constraintName is null in MySQL

Hello, I have a code using JPA with Hibernate 3.3.x. This Java code can be used with schemas stored either on Oracle 10g or MySQL 5.1.x. Tables are defined with constraints to define unique records. When a constraint violation occurs, I want to retrieve the constraint name from the exception. With Oracle, the constraint name is properl...

Hibernate : Downside of merge() over update()

I'm having problems with a NonUniqueObjectException thrown by Hibernate. Reading the docs, and this blog post, I replaced the call from update() to merge(), and it solved the problem. I believe I understand the reason for the exception, and why changing the method fixed the problem, in terms of disconnected objects and session boundar...

Does Hibernate auto-rollback programmatic transactions when unhandled exception occurs?

When working with programmatic transactions in Hibernate, is it necessary to explicitly call rollback if an exception occurs, or will the framework take care of calling rollback if there is an unhandled exception? The code below seems like the safe approach (albeit ugly code) to ensure rollback, but i'm wondering if there is a more elega...

How to trace sql commands for a specific connection to db2?

I am in the process of setting up a central build server. The server is responsible to produce the official build artifacts that will be deployed to all environment. For one of the applications there is an build step that writes to a database. At deploy time we would need to run this build step to the appropriate environment. Since it is...

Storing Objects in columns using Hibernate JPA

Is it possible to store something like the following using only one table? Right now, what hibernate will do is create two tables, one for Families and one for people. I would like for the familymembers object to be serialized into the column in the database. @Entity(name = "family") class Family{ private final List<Person> famil...

Eclipse the import cannot be resolved after Java update

I have class that uses hibernate, I have included all required jars to classpath and class worked before Java updated itself. But now eclipse shows that it cannot resolve some hibernate imports. What could be solution to this? import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; ...

Hibernate: How to set NULL query-parameter value with HQL?

Hello, how can I set a Hibernate Parameter to "null"? Example: Query query = getSession().createQuery("from CountryDTO c where c.status = :status and c.type =:type") .setParameter("status", status, Hibernate.STRING) .setParameter("type", type, Hibernate.STRING); In my case, the status String can be null. I have debugged this and hib...

Strategies for designing a database (being accessed by hibernate) which will have alot of archivial data.

I am developing an application which will be integrated with thousands of sensors sending information at every 15 minute interval. Let's assume that the format of the data for all sensors is same. What is the best strategy of storing this data so that every thing is archived (is accessible) and does not have a negative impact due to larg...

Spring 3 + Hibernate WebApp tutorial

Are there any good tutorials how to start weppapp with Spring 3, eclipse and hibernate? ...

Strategy to enforce foreign key at service layer instead of db layer

Example: in my data model I have a many-to-many relationship between Role and Order, via a Permission table that have an extra column for the name of the permission. E.g., the 'admin' role can view and modify orderA, but only view orderB. The permissions' names are, of course, 'view' and 'modify'. In classic db design fashion, the forei...

Terracotta With Hibernate and EHCache

Head swimming with the product name soup at http://www.terracotta.org. Need someone to help clarify what I need. Background: app has some "legacy" persistence code that does not use Hibernate, but has a home-grown cache implementation. New entities are Hibernate enabled. What I want: to use Terracotta for Hibernate 2nd level cache. I t...

Hibernate not creating correct fields for Clobs in MySQL

I have a String in my Entity @Column(length=40000) @Lob private String introText; The column in my MySQL database that Hibernate creates for introText is a varchar(255), which doesn't jive with the column length or @Lob annotation. Any ideas? I'm relatively new to Hibernate, so I wonder if I'm missing any other settings or configura...