I have something like Person, and Address object(Person has an Address and other properties).
I update Address or other properties in one request. And in another request I'm searching through all persons. But sometimes I can see properties modified and sometimes I cannot.
Just making another request will return me either modified or u...
I'm having problem on JPA (Hibernate) Fetch Join :
Here is my JPQL query
SELECT n FROM News n LEFT JOIN FETCH n.profiles AS pr WHERE pr.id=?1
But it's not working. How can I make a query that filters on the list that is being fetched ?
...
I am new to Hibernate and JPA, and am having difficulty setting up a composite key, as defined below:
@Entity
@Table(name = Entity.TABLE)
@IdClass(EntityPK.class)
public class MyEntity extends Entity {
@CollectionOfElements
@JoinTable(name="items",
joinColumns = @JoinColumn(name="items"))
private ...
Hi
I m using JPA to insert a row
My update code as in here
Now i m inserting a row using this code
public void get_image (String id)
{
Object l = null;
try
{
em = this.getEm();
EntityTransaction entr = em.getTransaction();
entr.begin();
newa.Options o = new newa.Options();
newa....
I currently am trying to persist a collection using @OneToMany(cascade=CascadeType.ALL) for a simple list of objects. The table for Parent_Child gets created in MySQL but the keys for each object are not updated upon using SaveOrUpdate. Any idea what the issue is? (My parent key is defined and the children are generated). I add the child...
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 ...
Two entities:
public class Employee {
Company company;
Long employeeId;
}
public class Project {
Company company;
Long projectId;
Collection<Employee> employees;
}
Three tables:
Project whose primary key is {companyId,projectId}
Employee whose primary key is {companyId,employeeId}
Project_Employee whose primary key is {co...
Help to solve this issue: Spring+JPA+Hibernate+Oracle insert query showing but data not inserting into DB : One to One relationship, here query for One table is showing second table insert query not showing, also data not inserting into DB.
...
I have to tables I want to map to each other.
I want to populate 2 drop down lists: code_r and code_l.
When i choose a value from code_r, code_l should display only certain records.
In my database I have 2 tables:
Table code_r
===================
CODE INT
LIBELLE VARCHAR
And
Table code_l
===================
ID ...
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 definition for an id field in an entity that is mapped to a table in HSQLDB.
...
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "ID")
private Integer id;
...
But this does not seem to generate the an unique id; instead an attempt is made to insert null into the column which results in failure. If...
I am having troubles getting this working and I wonder if what I am doing simply does not make sense?
public class Application {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="id")
private long id;
....
}
@MappedSuperclass
public abstract class Sample {
@Id @GeneratedValue(strategy = Generatio...
How do you join across multiple tables in an efficient way using JPQL
select a.text,b.text,c.text,
from Class1 a, Class2 b, Class3 c
where a.id=b.b_id and b.id=c.b_id and a.text like ... and b.text like ...
I am doing something like this, the tables only have a few thousand rows, yet the query takes 5-6 seconds to run. I assume it is ...
Dear members,
How to get value of some fields in a native query (JPA)?
For example I want to get name and age of customer table:
Query q = em.createNativeQuery("SELECT name,age FROM customer WHERE id=...");
Note: I don't want to map results to entities. I just want to get the value of the field.
Thanks
...
Hello guys,
I have a small problem here and hope that someone can help me out.
I wanna do a mapping from Object to Integer. The Object is marked as Fetchtype.Lazy.
When I do the mapping I get the following error message:
11:31:46,569 ERROR MappingProcessor:253 - Field mapping error -->
MapId: null
Type: null
Source parent clas...
Hi,
I'm using Hibernate/JPA and have an @Entity object called Order, pointing at a MySQL database using Hibernate's dynamic table generation i.e. generate tables at runtime for entities. When Hibernate creates the tables, it creates tables for all of my entities except the Order entity. If I rename the Order entity to something else e.g...
I have an entity that has few fields. One of them is city name. Now I want to get list of all distinct cities from that table. How can I archive that. I tried using DISTINCT keyword, but it doesn't work.
I'm using Hibernate as JPA provider but I would like to get it in pure JPA Query.
...
Hello,
I'm using JPA+Hibernate with a PostGre SQL database in a J2SE project.
I have 2 entities A and B. A has a @OneToMany relationship to B.
In my domain model A might reference millions of B's. When I add a new object to the collection it takes minutes to complete.
@OneToMany(cascade=CascadeType.PERSIST)
Collection<B> foo = new Arra...
We have a query which needs to check if a certain integer field points is not null and if appointmentDate is before current date? How do I write the restrictions expression for the above scenario?
@Entity
public class User {
...
Integer points;
Date appointmentDate;
...
}
...
Is this true?
http://stackoverflow.com/questions/2756307/what-is-the-equivalent-of-jpa-in-net
The marked answer shows a bunch of implementations. My understanding of JPA is that it is a specification?
What would be the equivalent specifications in .NET?
Would it be Linq Providers? And maybe the connection classes?
...