Colleagues,
Using JPA I need resolve following issue: at database level exits 3 entities (saying SuperEntity, DetailsAEntity and DetailsBEntity). SuperEntity contains common part of fields for DetailsAEntity and DetailsBEntity.
So the question: is it possible to resolve collection of mixed elements DetailsAEntity and DetailsBEntity from...
I'm trying to get data from assotiation N:N, but I receive blank field.
There are my Hibernate mapping class:
@Entity
@Table(name = "companies")
public class Company extends NamedEntity {
//some_code
@ManyToMany(
targetEntity = com.hqcargo.shippingstock.domain.CompanyProfile.class,
cascade = {CascadeType.ALL, CascadeTy...
I am somewhat new to using JPA -- I'll put that out there right off the bat. I'm getting more familiar with it, but there are big holes in my knowledge right now.
I am working on an application that uses JPA, and deletes entities using the EntityManager.remove(Object entity) function. However, the application also links into a third-par...
I'm writing an administration part of the application which is responsible for CRUD operations. I decided to generate the jsf pages from the jpa entities but for some reason I keep getting this error:
org.apache.jasper.el.JspELException: /busStop/List.jsp(18,12) '#{busStop.pagingInfo.itemCount == 0}' Error reading 'pagingInfo' on type j...
I have several mapped objects in my JPA / Hibernate application. On the network I receive packets that represent updates to these objects, or may in fact represent new objects entirely.
I'd like to write a method like
<T> T getOrCreate(Class<T> klass, Object primaryKey)
that returns an object of the provided class if one exists in ...
In the spring documentation regarding testing, it states:
Avoid false positives when testing ORM
code
When you test code involving an
ORM framework such as JPA or
Hibernate, flush the underlying
session within test methods which
update the state of the session.
Failing to flush the ORM framework's
underlying sessi...
I m able to get values using JPA when i have only mapped one table
Now when i have gone for mapping related tables i get the error
Only one may be defined as writable, all others must be specified read-only.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[userId1]
I m using [EclipseLink-0] (Eclipse Persistence Services...
I have a query like this
Query importQuery = advertiserDao.getEntityManager().createNativeQuery(
"select matching_type from group_key where key_id = " + Key.getkeyId());
String match = (String) importQuery.getSingleResult();
The matching_type is a enum('good', 'bad', 'repared') type. This gives an exception as following:
java.la...
I am using JPA 2 for an enterprise application, and my DBA's just hit me with a twist.
They want me to use the group's centralized object ID generator for all my tables. This means rather than using table values or a sequence table, I will need to call a web service to get a batch of ~50 ids.
Then, as I persist any new object, I would...
Hi, I have an entity
@Entity
@NamedQueries({
@NamedQuery(name = "Item.findAll", query = "select i from Item i"),
})
public class Item implements Serializable, WithId, WithNameDescription {
@Lob
byte[] photo;
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true)
TextualInfo english = new TextualInfo();
// more e...
Hi!
I'm alwways getting the following error:
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '2-1' for key 'PRIMARY'
Error Code: 1062
Call: INSERT INTO ENTITY_ENTITY (relationships_ID, Entity_ID) VALUES (?, ?)
bind => [1, 2]
Query: DataModifyQuery(sql="INSERT INTO ENTI...
Hi,
I'm new to JPA and now stuck with a problem!
I have two tables Person and PersonAddress.
In the Person entity, I have
@OneToMany(mappedBy="personid")
private Set<Personaddress> personaddressCollection;
and
public Set<Personaddress> getPersonaddressCollection() {
return this.personaddressCollection;
}
public void setPerson...
Hi,
I am writing a simple web application to call a stored procedure and retrieve some data.
Its a very simple application, which interacts with client's database. We pass employee id and company id and the stored procedure will return employee details.
Web application cannot update/delete data and is using SQL Server.
I am deploying ...
What does EntityManager.getSingleResult() return for a COUNT query?
So.. what is the precise runtime type of foo?
Object foo = em.createQuery("SELECT COUNT(t) FROM com.company.Thing t WHERE prop = :param")
.setParameter("param", value).getSingleResult();
...
First I need to acknowledge the fact that I'm new to EJB, JPA and Spring, so many of the things I believe as true could be wrong.
I'm building an EJB application where there's an stateless session bean used to retrieve many JPA (Hibernate) entities. The problem, which I believe is a widespread problem, is that I cannot traverse the rela...
Hi!
I'm using JPA to load and persist entities in my JEE-based web application. Hibernate is used as an implementation of JPA, but I don't use Hibernate-specific features and only work with pure JPA.
Here is some DAO class, notice getOrders method:
class OrderDao {
EntityManager em;
List getOrders(Long customerId) {
Query q =...
There are three object entities: GrandParent, Parent and Child
GrandParent contains grandParentId
Parent contains object GrandParent, parentId, some attributes, and a list of Child.
Child contains childId and some attributes.
There are four tables: GrandParent, Parent, Child, ParentsChildrenList
GrandParent whose primary key is {gr...
Hello.
I have a database in which an entity (say, User) has a list of entities (say, List). As a requirement, I must have a denormalized count of the entities on the list:
@Entity
class User {
/* ... */
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<Friendship> friends;
public int friendsCou...
I am looking for a tool to help in designing and implementing database and entities for a Java project. Probably we are using JPA or direct Hibernate. The features I look for are:
Design database with visual modeller
Create entities from the visual model
Update entity changes to the visual model
Import existing database schema as visua...
Hi,
I have an application deployed on Glassfish v3.0.1 which reads events from a table in my database. Once ready it marks them as processed. I am getting a strange error I can't explain when trying to call the method which does the update.
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void markEventAsPr...