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 Class CustomDate and that is referred in other class called Test.
public class CustomDate{
public String toString(){
return "20100829"
}
}
public class Test{
CustomDate date;
}
In Mapping file of Test
<property name="date" COLUMN="DATE">
I want to save only long value and type should be long type and i s...
I want to create my database tables automatically with Hibernate and Postgresql, but I get errors about sequences. Is it possible to auto create sequences too with Hibernate, or do I have generate sequences manually?
Example of my entity:
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence...
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'm working on building an app with Kohana 3.0.7, using the ORM module. I want to build an object, such as tag, where many different kinds of objects can be tagged, and these options can have multiple tags. So let's say for example I have 3 models: Tag, Post and Page. how would I structure the tables and the models to make this work bes...
Suppose I was writing an application where users had to book appointments (in my case, a user is paired with an employee and that employee will do work for that user at a particular time of day). How would I ensure that 2 users did not end up booking the same appointment using NHibernate or Entity Framework? Would I open a transaction an...
Hi Friends,
I am new to this forum. I am facing a strange problem. I get below mentioned stack trace though the data gets inserted successfully.
Hibernate: select attendee_.attendeeId, attendee_.attendeeName as attendee2_1_ from attendee attendee_ where attendee_.attendeeId=?
Hibernate: select attendee_.attendeeId, attendee_.attendee...
If I'm developing a hiberante application, am I also developing a DD model?
My application does have a service layer ( which is in lines with the Observer pattern). Will there also be a Domain Layer wherein all the hibernate entities exist?
I'm looking my application somehting like this:
Do I need to know Domain Driven Design to wri...
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 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...
Does the Entity Framework 4 have ordered collections?
For example my Order has a property that is a collection of OrderItems, but the order is important and I would rather not sort them before I access them.
See Nhibernate for an example:
http://stackoverflow.com/questions/1916350/set-bag-and-list-set-in-nhibernate
...
Been trying to figure this out for a couple of hours now and have gotten nowhere.
class other(models.Model):
user = models.ForeignKey(User)
others = other.objects.all()
o = others[0]
At this point the ORM has not asked for the o.user object, but if I do ANYTHING that touches that object, it loads it from the database.
type(o.us...
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
...
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 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...
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;
...
}
...
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...