I'm trying to map an entity using Hibernate Annotations, so that when a record is created and saved (via cascade), an ID is automatically generated. With my current setup (or a few others I've tried) I get the following error:
...org.hibernate.exception.ConstraintViolationException:
could not insert: [com.gorkwobbler.shadowrun.karm...
I want to serve an image saved as a blob in a MySQL Database through hibernate3 in a JSF application. My intention is that /myapp/image/get.faces?id=x will serve the image saved in the database with id x. How to achieve this?
...
I'm starting to lose faith in Hibernate. It has caused me nothing but weird problems throughout the last few days.
Upon deleting an entity from the database I get the following exception:
org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
at org.hibernate.collection.AbstractPersisten...
Hi,
I am using Hibernate Tools to generate the DAO and classes straight from database. There are two tables (table A and B) in the database, and there is a one to many relationship from A to B (multiple rows in B mapped to single A).
In the generated code of A (class A), there is a collection of class B, which reflects the one to many ...
I made a class called SpecializationBean which has two private fields:
private ArrayList<SelectItem> specializationItems= new ArrayList<SelectItem>();
private String specializationName;
I have ofcourse a getter and setter for those two.
and a buildSpecializationList method which builds the specializationItems list: (I call this metho...
I have feilds which is available in all domain obejcts.Those feilds are, created_By,Created_date, Modified_By, Modified Date. Can i declare/have like CorebusinessObject which contains these four feilds, and extending this into other object. Is it good design? If so, How could i do ORM mapping.
...
How to achieve @MappedSuperclass logic using Hibernate ORM mapping?
...
Is there a way to load only selected entities with Hibernate?
I would like to only load a selected handful for integration testing.
...
Hi,
In my domain model I have a bi-directionnel association between the ProductList entity and the Product entity with the following hibernate mapping :
@Entity @Indexed
@Table(name="product_list")
public class ProductList {
@ManyToMany(fetch=FetchType.LAZY)
@JoinTable(name = "list_items",
inverseJoinColumns = { @JoinColumn(na...
Hibernate allows you to just say ".id". Let's say I have:
@Entity public class Customer {
@Id private Integer customerId;
@Basic private String customerName;
// getters and setters
}
And I want to get the name of a customer by ID:
SELECT cust.customerName FROM Customer cust WHERE cust.id = :customerId
Notice I put "id" rathe...
Our Java application has about 100 classes mapped to a database (SQL Server or MySQL). We are using Hibernate as our ORM (with XML mapping files).
We specify FOREIGN KEY constraints in our database schema. Most of our FOREIGN KEY constraints also specify ON DELETE CASCADE.
We've recently started enabling Hibernate 2nd level caching (fo...
For testing purposes, I'd like to have a console where I can just enter an HQL command and see what it returns on the grails hibernate DB (in my case a MySQL DB) while it's running e.g. in the test environment. What's the best way to do that?
I'm using Eclipse and already came across the JBoss Hibernate Tools, but I'm not sure how to co...
Sadly, I forgot to take the code from work with me today. But maybe this little example will clarify things.
I use hibernate to map a bean to a table.
Example:
import javax.persistence.column;
….
String columnameA;
….
@Column(name="columnameA")
public String getColumname(){
return columnameA
}
….
I do not want to hardcode the colu...
Hi all,
This question is related to "Hibernate using JPA (annotated Entities) and liquibase".
I was actually wondering what to expect when doing a Liquibase diff against a Hibernate mapping definition.
What it seems to produce: A liquibase changelog that migrates the state of my hibernate mappings to the current image of the database....
I have been using hbm2ddl and hbm2java to build my database and POJOs for my project based on my XML mapping files (hbm.xml). I'm starting to get some real data now in the system, so re-running my ant script which drops the database and recreates everything is no longer a viable option since I want to keep the data. I have heard that the...
Please tell me, what am I doing wrong.
I have this function:
public String create(){
try {
Iterator<Tag> it = tags.iterator();
List<Tag> tagList = new ArrayList<Tag>();
while(it.hasNext()){
Tag t = it.next();
if (projectsTags.contains(t.getName())) {
...
Hi,
In one of my hibernate classes I've a Timestamp variable. Now everything was alright when I used only the hibernate stuff on the server. But now I'm implementing webservice with wsgen.
I get an error because Timestamp doesn't got an no-args default constructor.
Message;
Caused by: java.security.PrivilegedActionException: com.sun....
Hello, I have a Java object with a field that needs to be auto-incremented in the database. This field is not a primary key, just a field that needs to be auto-incremented.
My question is what value I need to set this field in my Java object before doing a session.save(Object)? Do I have to set it to NULL?
How would the Hibernate mapp...
I wonder if there is a way to retreive domain instances as a Map where the key is the id of the domain object.
more specific i would like to do myDomainObject.list() to return a Map instead of a List.
...
I am trying to create an index on a particular text string using Hibernate annotations. What I am currently doing is:
@Index(name="guid_index")
@Column(length=1400)
private String myGUID;
However, since the length of the column is 1400, this maps to SQL using the longtext type. hbm2ddl is able to create the table without mishap, but w...