Hello everybody i wonder: when can i use mapped by to indicate whose is owing of relationship in one-to -one or one to many - or many to many relationship mapping with EJB3 (JPA)
example
i have two table A and B
table A belong to table B
so what i place mapped by for whose table?
...
This is something I'd really like to be able to do - resolve names based on id values without fetching the whole child model.
Here is an example of what I have, a Table say Employee and a Name_Details table
The Employee may look like this
Create Table Employee {
emp_idinteger not null generated by default as identity; -- generated pk...
Why would the following query fail due to a foreign key constraint? There is no other way for me to delete the associated data that I am aware of.
Query query=em.createQuery("DELETE FROM Person");
query.executeUpdate();
em.getTransaction().commit();
The I believe the offending relationship causing the problem is the activationKey fiel...
It is possible to do the equivalent of this sql query in JPQL?
SELECT *
FROM COUNTRIES c WHERE COUNTRY_ID IN (
SELECT DISTINCT COUNTRY_ID
FROM PORTS p
WHERE p.COUNTRY_ID = c.COUNTRY_ID AND STATE = 'A'
)
...
I have a question about JPA-2.0 (provider is Hibernate) relationships and their corresponding management in Java. Let's assume i have a Department and an Employee entity:
@Entity
public class Department {
...
@OneToMany(mappedBy = "department")
private Set<Employee> employees = new HashSet<Employee>();
...
}
@Entity
public clas...
I need to assign the result of a jpql result to a simple class java object
I have something like this
class myObject() {
@id
private Long id;
private String Name;
private String description;
...
//getters and setters
}
I need to somehow to store the result of this SQL query, example
// could be anytable
SELECT DISTINCT c.table_i...
I'm deploying a simple Java app to Google App Engine.
I have a simple JPA Entity containing a Key as my generated ID.
import javax.persistence.*;
@Entity
public class MyEntity
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private com.google.appengine.api.datastore.Key key;
...
Once I persisted this ob...
Hi,
We are in a middle of an migration process of converting EJB2.1 entity beans to EJB3 we have chosen Hibernate as JPA 1.0 provider in Weblogic.
We would like to disable auto. increment of entity version when persisting. Is it possible to turn of this feature? (as in property or persistence.xml?)
Do JPA 1.0 support pessimistic lo...
Hi All,
I have an error in setting up Java Persistence in Netbeans. I have used MySQL as Back-End Database Server.
My Code is as below,
Database
CREATE TABLE `hub` (
`hub_ID` INT(11) NOT NULL AUTO_INCREMENT,
`hub_Name` VARCHAR(45) NOT NULL,
PRIMARY KEY (`hub_ID`),
UNIQUE INDEX `hub_Name` (`hub_Name`)
)ENGINE=MyISAM
CREATE TABLE...
I'm using Hibernate and Derby. I've this class:
public class Sensorboard {
//...
@ManyToMany(fetch=FetchType.LAZY)
@JoinTable(name="SENSORBOARD_SENSORBOARD_JOIN",
joinColumns=
@JoinColumn(name="SENSORBOARD_ID", referencedColumnName="ID"),
inverseJoinColumns=
@JoinColumn(name="NEXTSENSO...
I have a webapplication using Hibernate and Jpa and want to add search via hibernate-search.
I use the following hibernate versions:
hibernate-core-3.3.2.GA
hibernate-annotations-3.4.0.GA
hibernate-entitymanager-3.4.0.GA
hibernate-search-3.2.1.Final
And for lucene:
lucene-core-2.9.3
The following code compiles perfectly fine:
public Li...
Is there any way that Criteria for qureies can be built on a remote (Swing/SWT etc) client? We've been using the DetachedCriteria functionality in Hibernate for quite some time, but would like to use standard JPA 2.
If not, could the code from hibernate be re-factored to create the remote API? Or is this something that might come alon...
Can we cache reference to EntityManager.
As for our requirement, instead of injecting EntityManger into other EJBs, we are having utility class which will return the reference to entitymanager.
The issue is each time we need to get reference, we are doing JNDI lookup.
in order to avoid JNDI lookup, we want to cache the reference to ent...
For a new project we are starting (which uses JPA 2 on top of Hibernate 3) we need to be able to store XML documents and then query on their content and structure at a later date. The databases we would like to support are DB2, Oracle and SQLServer.
I know all three DB vendors support native XML querying (using SQL and XQuery like state...
Hello,
I would like to have a JPA Entity that has a GSon Object as a field/attribute. For instance:
@Entity
public class MyEntity {
private JsonObject myObject;
public JsonObject getObject() {
return myObject;
}
public void setObject(JsonObject obj) {
myObject = obj;
}
}
I'm not familiar with ...
Is it possible to use an enum as a discriminator value when using SINGLE_TABLE inheritance strategy?
...
There are two JPA entities: User and Order with one-to-many relationship.
/**
* User DTO
*/
@Entity
@Table(name="user")
public class User implements Serializable {
private static final long serialVersionUID = 8372128484215085291L;
private Long id;
private Set<Order> orders;
public User() {}
@Id @GeneratedValue(s...
Looking for a really good article that includes strategies/bugs/workarounds. I would prefer a pure JPA solution but I know Hibernate offers a lot of extensions.
...
Hi, folks. I am working on a JPA setup with optimistic locking (@Version) and EHCache. The underlying provider is Hibernate.
I hooked a HibernateDirtyCheckInterceptor (extends EmptyInterceptor) into the Spring config file. This part is working, as my log entries get posted. My entity class clearly defines itself as not dirty, and the fi...
I'm working with Spring Roo and I need to overwrite Roo's Remove() method in the Roo_Entity.aj file. I'm getting a lot of Foreign Key constraint errors when I try to delete my entity, although I think my JPA annotations are correct.
What I'm trying to do is overwrite the Remove() method in the Roo_Entity.aj file, to manually check for ...