Say you generate ddl to create all your db tables etc via Hibernate SchemaExport etc. What you get is a script which starts with drop statements at the beginning. Not a problem, as I want this. But running this script produces a crapload of ORA-00942 errors running on an Oracle db.
Since they're not really errors if the tables just...
HI
i am using struts and hibernate. i have a parent and child relation using set in hbm.
in the action i am using session.saveOrUpdate() method to save but while saving it is showing the below error. can anyone help regardng this with explanation where i made the mistake
here is my hbm.file
<?xml version="1.0"?>
<!DOCTYPE hibernate-m...
Hi,
I'm writing a web app that supports multiple users. Each user has their own database - using H2. all database schemas are the same.
I wish to use Spring + Hibernate for this application.
So I'm stuck at how to associate a user's database with that user - maybe associated it in the HTTPSession, and extend spring's AbstractRoutingDa...
I was reading an article in which the author had implemented an Entity class like this:
@Entity
public class Product {
@OneToMany
private List<Part> parts; // note the missing "= new ArrayList<Part>();"
public Product() {
}
// getters and setters
}
I always used to instantiate collection fields, in this case parts, either inl...
I would like to use JPA2 Criteria API with metamodel objects, which seems to be pretty easy:
...
Root<JPAAlbum> albm = cq.from(JPAAlbum.class);
... albm.get(JPAAlbum_.theme) ... ;
but this Root.get always throws a NullPointerException. JPAAlbum_.theme was automatically generated by Hibernate and looks like
public static volatile Sing...
The object structure is like below-
Entity A
- Collection <B>
Entity B
- Collection <C>
Entity C
-Collection <D>
Entity D
CompositePrimaryKey
Class CompositePrimaryKey
String id;
In the HQL, the query is like from A a where a.B.C.D.CompositePrimaryKey.id = 'input';
I am getting the below exception-
org.hibernate.QueryE...
Hi,
I've got an issue with Grails where I have a test app with:
class Artist {
static constraints = {
name()
}
static hasMany = [albums:Album]
String name
}
class Album {
static constraints = {
name()
}
static hasMany = [ tracks : Track ]
static belongsTo = [artist: Artist]
String name
}
class Track {
static constraints...
This is my code, which I can't even compile:
/**
* Find a project that has NO employee assigned yet.
*/
public Project findEmptyProject() {
// getting criteria builder
CriteriaBuilder cb = this.em.getCriteriaBuilder();
// gathering meta information about left-joined entity
Metamodel m = this.em.getMetamodel();
EntityType<Emp...
This might be a super easy answer, since I'm sure it's not uncommon. I see some similar questions, but nothing that seems to describe my problem.
I have two objects: a car and person. They're in a many-to-many relationship, i.e. a car can be owned by multiple people, and a person can own multiple cars. Car has a lazily initialized se...
I'm at a loss of how to create a running sum of particular field after creating a criteria within a controller
I'm currently creating a set of set of records using:
def b = Tapes.createCriteria()
def yesterday = b.list(sort: 'migratedDate', order: 'asc') {
between ("migratedDate", dat.minus(1), dat)
}
and counti...
I use Hibernate with annotations. I need to insert object into the database using a method who needs one parameter that I need to calculate, to do this I use:
SQLQuery sqlQuery = getSession().createSQLQuery(queryString);
sqlQuery.executeUpdate();
The queryString contains:
INSERT INTO TABLE(ID, NUMBER) VALUES (SEC_TABLE.NEXTVAL, 549)
...
I used ImprovedNamingStrategy in hibernate, to mapping Java field name to MySQL column name.
ex) birthDate field -> birth_date column, AccountRole class -> account_role table
I'm doing test migrating hibernate code to eclipselink code.
What is the equivalent in EclipseLink to hibernamte's ImprovedNamingStrategy ?
...
Hello,
I have a class that contains a list of objects, say a list of cars :
class Garage
{
public virtual List<Car> cars
{
get;
set;
}
}
The reason I can't directly serialize this list is that the type Car could have a lot of subclasses, and themselves could have other subclasses, and I'd like to avoid upd...
I have created a class in which I have set some of it's fields (other entities) to be LAZY loaded. Now I need to use this object after it has been detached from the session, so I obviously need to make sure all the fields that I need are populated before detaching it. I tried just calling the getters to these lazy fields but that didn't ...
Hi,
I am using one named query to search some result in my Project.
e.g ( from StructureEventDAO as se where se.Structure.StructureId = :StructureId and se.eventMaster.eventName =:eventName ).
This is giving proper result if I pass required both the named parameter value.
I just wanted to know what if runtime I have one of the parame...
Why does the following HQL query fail?
string hql = @"delete MyLog log
where
log.UtcTimestamp < :threshold and
log.Configuration.Application = :application";
session.CreateQuery(hql)
.SetDateTime("threshold", threshold)
.SetEnum("application", this.application)
...
Hi All
Short Summary of Problem
Hibernate is assuming that whenever someone is using subclass all the columns should be created in the top root of the class hierarchy irrespective of what table name has been provided. Can someone please explain the reasoning behind it and if there is way to bypass this code and somehow avoid invoice_id...
Hello
I have two tables (folder and document) which have a many to many relationship with a join table in between, this join table then also has another one to many relationship with a third table (document_title).
I want to be able to fetch a document_title from a document, what is the correct way to model this in hibernate?
The obj...
Hello there,
I'm rewriting some messy code that manages a database, and saw that the original programmer created a class mapped to the database like so:
(I've removed unnecessary code that has no purpose in this question)
@Entity
@Data
@EqualsAndHashCode(callSuper = false, of = { "accessionCode", "header", "date" })
@SuppressWarnings(...
I have a class A which has set of class B. class A and class B has their own table.
When i insert class A it also insert class B. When i update class B, Hibernate deletes everything from class B which belongs to that instance of A and then insert all values in current set B. I want that if only 2 new values are added in set b, then it on...