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...
When there are no rows, both query.list() and criteria.list() are returning empty list instead of a null value.
What is the reason behind this?
...
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 need to fetch only specific feilds instead of all fields. All my tables has audit feilds(4) . i want that to be ommitted on the selection. how to do that from mapping. is there any other way?.
Criteria criteria = session.createCriteria(Property.class, "property")
.createAlias("property.propertyType", "type").createAlia...
I'm using query by example and I have an object which has two child objects. The problem I have is I want to make a query which has limitations for both child tables and I cant work out how you do it. When I do this:
List results = session.createCriteria(Cat.class)
.add( Example.create(cat) )
.createCriteria("owner")
...
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...
Hi,
I have a the following use case where I'm receiving a message via JMS regarding an entity, via a unique property of it (not PK) and it requires me to update the state of the entity:
HibernateUtil.beginSession();
HibernateUtil.beginTransaction();
try{
Entity entity = dao.getEntityByUniqueProperty(propertyValue);
if (ent...
Hello,
We have a data acquisition application with two primary modules interfacing with DB (via Hibernate) - one for writing the collected data into DB and one for reading/presenting the collected data from DB.
Average rate of inserts is 150-200 per second, average rate of selects is 50-80 per second.
Performance requirements for both...
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;
...
}
...
Hi,
I have 4 web applications, that have a common reference to an Hibernate implementation but that run on different Tomcat instances. And so, for example, a connection pool configured in Hibernate with a min size of 3 (with c3p0), will result in 12 connection open (3 for each instance) when all the projects are running .
I'd like to "...
Hi Guys,
I am preparing a document for a project. The project's backend is developed in Java, frontend is adobe flex.
I am not sure about the correct way of describe the project in Model-View-Controller way.
For Model layer: Using Hibernate Java beans to implement all the business logic and persistence?
For View Layer: Using Adobe ...
I just installed MyEclipse and have not located a tutorial using MyEclipse with Spring 3 and Hibernate. I would appreciate it if anyone could refer me to such a tutorial.
Thanks.
...
My infuriating problem of the day is this:
I'm trying to use Hibernate to access a database. After a number of false starts, I gave up on my specific project and elected to use the sample database and wizards that shipped with Netbeans 6.9.
I fired up Netbeans, started the sample Derby database, and followed the instructions in this tu...
Currently, my project uses @Enumerated(EnumType.ORDINAL), so when I sort by this column, it is ordering based on the order in the enum, which works fine. But I need to add some additional values to the enum, which need to be inserted at different locations in the list of enum values and can't be just added to the bottom to maintain the c...
Hibernate 3.3.x
@Entity
public class User {
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@OnDelete(action = OnDeleteAction.CASCADE)
@Cascade(value = DELETE_ORPHAN)
@OrderBy
private List<Phone> phones= new ArrayList<Phone>(0);
...
}
Cascade delete is not enabled if you have some ...
when we load hibernate using spring we have to just call methods for CRUD function but what exactly Spring hibernate do to fire query
...
Hello!
I have following structure of my entities:
@MappedSuperclass
public abstract class BaseEntity {
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqGenerator")
private Long id;
}
@MappedSuperclass
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@SequenceGenerator(name = "seqGenerator", sequenceName...
I have an entity class and another class is Identity class of this entity.
I have written @javax.persistence.PostLoad annotation in Id class to put some default value on one of the column.
But I found out that it is not being called at all. Is it that ID classes should not have this annotation?
...