Hi,
I am new to JPA.So my question would sould so simple to some. :)
Below is the Simple Query in SQL which i would like to convert to JPA.I already have the an Entity Class as TimeEnt
SELECT SUM (TimeEntryActualHours) As UnBilledHrs,SUM (TimeEntryAmount) As UnbilledAmount
From TimeEnt Where MatterID = 200;
Thanks a lot for you hel...
I created the JPA 2.0 entity classes for our whole database (~200 tables), and now each time I rebuild my application and start it for the first time I get these messages:
INFO: <entity_classname> actually got transformed
INFO: <entity_otherclassname> actually got transformed
...
And the output of these (info) messages in Glassfish is...
Is the criteria api of eclipselink jpa2 supported for java se 6 projects? If not, that's my problem.
Do I need to specify anything special to the criteria api in the persistence.xml?
This is my criteria query:
final EntityType<Meaning> Meaning_ = em.getMetamodel().entity(Meaning.class);
final CriteriaBuilder cb = em.getCriteriaBui...
Why can i remove elements of a bidirectional relation although only one side of the relation is managed in persistence context (Example I)? When i have an unidirectional Relationship that doesn't work (see Example II). Why?
Entities:
@Entity
Class User {
...
@OneToMany(mappedBy = "user")
private List<Process> processes;
...
Is there a way to select specific column using the JPA 2 Criteria API?
The following is the target SQL Statement:
SELECT column1, column2 FROM MyTableThatHasMultipleColumns
With Hibernate's Criteria API this can be done using Projections, is there an equivalent to the JPA 2 Criteria Specification?
...
I'd like to use JPA along with Bean Validation, so JPA 2.0 sounds like what I need. I'm running my web application on Tomcat 6. Is Tomcat able to use JPA2?
...
I have an existing working query that selects a column from an entity mapped to an Oracle View using the following JPQL
SELECT COUNT(o.id) FROM MyEntityView o
I refactored it to use the JPA 2 Criteria API with the following code:
MyEntityView model = new MyEntityView();
CriteriaBuilder criteriaBuilder = model.entityManage...
I have a @ManyToMany relationship between two entities. When I perform an update on the owning side, it appears that JPA deletes all the linked records from my database and re-inserts them. For me this is a problem because I have a MySQL trigger that fires before a record is deleted. Any ideas on how to get around this problem?
Thanks R...
I get:
diagnostic error: javax.annotation.processing.FilerException: Attempt to recreate a file for type
for:
<compilerArguments>-Aeclipselink.persistencexml=src/main/resources/META-INF/persistence.xml -Aeclipselink.persistenceunits=com.mysimpatico_MemoPlatform-database_nbm_1.0-SNAPSHOTPU,com.mysimpatico...
Hi
I m using JPQL to retrieve data. I can get data using the statement
List persons = null;
persons = em.createQuery("select p.albumName from PhotoAlbum p , Roleuser r
where r = p.userId and r.userID = 1");
Now i can get the album names using this...
int i=0;
for (i=0;i<persons.size(); i++)
{
System.out.println("Testing n "...
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...
I am using the Hibernate 3.5.1 and EntityManager for data persistence (with JPA 2.0 and EHCache 1.5). I can obtain the query by the following code:
EntityManager em;
...
Query query = em.createQuery(...);
...
Now, the problem is that EntityManager's createQuery() method returns javax.persistence.Query which, unlike org.hibernate.Query...
When using Blob-fields in n-to-m-relations Hibernate and MSSQL are failing for some reason.
SQL Error: 421, SQLState: S0001
The image data type cannot be selected as DISTINCT because it is not comparable.
...
could not initialize a collection: [Dataset.documents#someID]
My classes look as follows:
@Entity
class Dataset {
@OneToMa...
I have two entities: Project, Employee
Employee has primary key {employeeId} + some other attributes
Project has primary key {projectId}
Code:
public class Employee {
Long employeeId;
String name;
}
public class Project {
Long projectId;
Collection<Employee> employees;
}
Employee and Project is a one way many-to-many ...
Hi all
Could someone provide a simple example that demonstrates how to implement a simple "update" method? This one does not update
@Override
public void update(final BS bs) {
BS fullBs = em.find(BS.class, bs.getId());
BS merged = this.em.merge(fullBs);
this.em.flush();
}
Thanks
ER
...
I have the following database tables:
party, with a pk "pty_id" connected to a sequence for generating pk values.
person with a fpk "prs_pty_id" in an identifying relation to party.pty_id.
company ... which is not involved at the moment, but obviously this is kindof sub-superclass setup, and it could probably have been implemented with...
I am stuck with a problem concerning JPA-2.0 queries with relationships. How would it be possible to select any Dataset with at least one Event with type = B?
@Entity
class Dataset {
@OneToMany(fetch = FetchType.LAZY, mappedBy = "dataset")
public List<Event> events;
}
@Entity
class Event {
@ManyToOne
@JoinColumn
pub...
How can I formulate the following JPA2 criteria query without using the metamodel classes:
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Employee> cq = cb.createQuery(Employee.class);
Root<Employee> emp = cq.from(Employee.class);
cq.where(cb.isEmpty(emp.get(Employee_.projects)));
cq.select(emp);
I wou...
Hi guys,
I am trying to create a new JEE project using hibernate and JPA 2.0 on the glass fish server.Can you guys provide me some resources to configure the above so that they work seemlessly. I have tried using netbeans and generated the persistence unit by using the hibernate provider,but i end up getting this error
javax.persi...
If I want something like that with EclipseLink and JPA 2.0
SELECT ... FROM ... WHERE name1=value1 AND name2=value2 OR name3=value3
Which is the best way?? In the oficial say somthing like:
cq.where(cb.equal(pet.get(Pet_.name), "Fido")
.and(cb.equal(pet.get(Pet_.color), "brown");
http://download.oracle.com/javaee/6/tutorial/doc/...