Hi there,
I know that truncateisn't supported so I do a Delete from table - this works quite good but the join tables aren't cleaned this way. Example:
Delete from Product;
Delete from Service;
both empty, table service_productis still filled. Is there a chance to clean my join tables without raw sql?
example entity
public class Se...
I started creating JPA/hibernate mappings for a legacy database based on Oracle. At one (early...) point I have a many-to-many relation between to tables (FOO, BAR, join table with extra fields: FOO_BAR). So I defined three entities, created an embeddable Id class for the join table, strictly following some examples from a good (?!) book...
I'm using Hibernate Annotations and trying to save an object. But when saving object I get:
Cannot insert the value NULL into column 'status'
The thing is that in my SQL Server 2008 configuration that field is defaulted to '0'. Now I dot not want to manually set the default value in my Java code like status='0', because I think this...
Hello all,
Let's say an Owner has a collection of Watch(es).
I am trying to create Watches and add the newly created Watches to an existing Owner's collection of watches (an arraylist).
My method is as follows:
public void add(String ownerName, String watchName) {
Owner o = new OwnerDAO().retrieve(ownerName); //retrieves owner o...
Hi,
In a scenario with two types of entities, Parent and Child:
Parent
- @OneToMany Collection children;
The default is to have lazy loading on the collection of children. This model works great for small numbers of children, but if the number grows very large this seems unsustainable. So for occasions where I think the number of chi...
Hello guys,
Here's the setup: the entity class has the collection of other entities that is loaded lazily. The trick is, I need to perform some data-related work (for example, I want to calculate certain checksum with the elements of collection).
The trick here is that I want to avoid at all costs the race conditions like: "someone ha...
I have a domain model that looks like this:
Instruction
| \
Money Other
/ \
Unit Cash
and I want to map this model to my DB using JPA.
All classes map to the same table in the DB, (T_INSTRUCTION).
So I started out with jpa's SINGLE_TABLE inhertance strategy. Separating the Money and Other classe...
I have JSF application with trinidad components and JAXB/JPA entity beans generated by Hyperjaxb3. In the UI I use Trinidad combo box component that has JPA object as values.
The scenario is:
User make selection in combo box
User clicks on a control that sends request to the server and is returned to the same form
Data from the form w...
Hi there,
is it possible to model a reference to "any" (entity) with JPA? Similar to a reference of type Object in Java, which can hold any object.
Thanks for your answer,
Dominik
...
I know that this topic has been discussed umpteen number of times, but still need some clarifications on the issue we are facing. Hibernate best practices talk about using natural keys for the equals / hashCode methods. We do have a composite key which consists of 2 parameters (say String name, Organization org) to which a particular obj...
Howto declare @Entity class for oracle table w/o PK?
I has received the error message:
Column "rowid" cannot be resolved on table "LOG"
when doing mapping like this:
@Entity
public class Log implements Serializable {
...
@Id
private ROWID rowid;
...
}
...
I am creating a billing system which manages a Ledger for each customer. Each Ledger has a list of LedgerEntry's which records each customer transaction.
As I was testing this, I noticed that if I created a bunch of LedgerEntry's within the same transaction, the @Id value was not in order that the objects were given to em.persist(), un...
Hibernate:
/* load entities.Department */ select
department0_.name as name4_0_,
department0_.id as id4_0_
from
J_DEPT department0_
where
department0_.name=?
Hibernate:
/* load one-to-many entities.Department.employees */ select
employees0_.dept as dept4_1_,
employees0_.i...
Hi,
Im learning JPA and having problems. My main problem is when i join my entitys and dont quite understand why im getting the results i am .. and its realy slowing my progress if someone could help i would be very greatful.
Entitys
College
@Entity
@NamedQueries({
@NamedQuery(name=College.allCollegeQuery,query="SELECT col FROM C...
I am using Hibernate JPA implementation org.hibernate:hibernate-entitymanager:3.4.0.GA at central maven repo. I have two classes.
Class A extends Class B
When I execute a query like "SELECT b FROM B b",
the result list, as expected, contains Class A instances too.
Is there a way to retrieve only the Class B instances without any fie...
Hi,
I have an entity which has a collection as one of its attributes.
That collection is mapped with a @ManyToMany annotation with fetch type lazy.
The target entity also has collections as attributes, some are @OneToMany and some are @ManyToMany.
When fetching the first entity (via entityManager.find(id)) its collection attribute is ...
I was reading this book. Explaing about "@OneToOne unidirectional", the author has taken the following Customer, Address example:
@Entity
public class Customer{
@Id @GeneratedValue
private Long id;
private String name;
private Address address;
//few other columns, getters/setters
}
@Entity
public class Address{
@Id @G...
Hi all,
I'm getting extremely weird behavior out of JPA 2.0 Criteria API with Hibernate 3.5.1-Final as a provider.
I'm trying to build a dynamic query that looks like this in JPQL:
SELECT e FROM Employee e WHERE lower(e.firstName) like lower(:employeeName) OR lower(e.lastName) like lower(:employeeName)
but keep getting the er...
I have problem mapping the parent/child relationship in JPA and currently down with the follow error message -
java.lang.IllegalArgumentException: org.datanucleus.exceptions.NucleusException: App Engine ORM does not support multiple parent key provider fields.
at org.datanucleus.jpa.EntityManagerImpl.find(EntityManagerImpl.java:232)
...
How to get the most recently added row from a certain table, which satisfies a certain condition.
If I use javax/persistence/Query.html#getSingleResult() we get a NonUniqueResultException if there are multiple rows satisifying the query. I need the equivalent of findOne from the list. I would prefer not to paginate by setting the rowsPe...