This is situation I have:
I have two entities with one-to-many relationship mapped like that (only relevant parts are given):
<class name="xyz.Survey">
<list name="answers" inverse="true" lazy="true" fetch="select"
cascade="all-delete-orphan">
<key column="OPA_OP_ID" not-null="true" />
<list-index c...
Hi.
Is it possible (using Hibernate and JPA2 Criteria Builder [1]) to order by a method's result rather than an entity's member?
public class X {
protected X() {}
public String member;
public String getEvaluatedValue() { // order by
return "a status calculated with various members";
}
}
What I want to achive ...
Hi
I am a newbie to Java persistence and Hibernate.
What is the difference between FetchType LAZY and EAGER in Java persistence?
Thanks
...
Does anyone know if you can use mySQL Cluster with Hibernate?
...
I am struggling to get my spring managed transactions to commit, could someone please spot what I have done wrong. All my tables are mysql InnonDB tables. My RemoteServiceServlet (GWT) is as follows:
public class TrainTrackServiceImpl extends RemoteServiceServlet implements TrainTrackService {
@Autowired
private DAO dao;
@Override
...
Hi,
I am using JPA and Hibernate for the database. I have configured (EHCacache) second level cache and query level cache, but just to make sure that caching is working I was trying to get the statistics which is throwing class cast exception.Any help will be highly appreciated. My main goal is to see all the objects which have been ca...
I am working on a J2EE server application which is deployed on Tomcat. I use Spring source as MVC framework and Hibernate as ORM provider. My object model has lot of Lazy relationships (dependent objects are fetched on request). The high level design is like Service level methods call a few DAO methods to perform database operation. The ...
Hi I am new to Java persistence.
Does it matter where I put the Annotations at?
Are the following two sets of the code the same?
Thanks a lot!!
@Entity
@Table(name="user", schema="billing")
public class User {
private long id ;
private String userName ;
private String password ;
@Id
@GeneratedValue
public lon...
Hi there,
I have a jpa mapping class with a polymorphic association like the following:
@Entity
class MyEnt {
private Long id;
private MyInterface mi1;
private MyInterface mi2;
//...
@Any(metaColumn = @Column(name = "mi1_type"))
@AnyMetaDef(idType = "long", metaType = "string", metaValues = {
@MetaValue(valu...
I would like to be able to extract the entity and property from the ConstraintViolationException message in a rdbms neutral way... Can this be done ? if so how ?
...
Hi All,
I was asked in an interview this question so I answered with the following:
-Better Performance:
- Efficient queries.
- 1st and 2nd level caching.
- Good caching gives better scalability.
- Good Database Portability:
- Changing the DB is as easy as changing the dialect configuration.
- Increased Developer Productivity:
...
Im getting following error while running the query.
org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found 'LIMIT' near line 1, column 194 [from com.claystone.db.Gpsdata where id.mobileunitid = '2090818044' and gpsdate in (select id.gpsdate from com.claystone.db.Gpsdata where id.mobileunitid = '2090818044' ORDER BY id.gpsdat...
I would like to convert following Query into HQL Query. How can i do?
select * from gpsdata where mobileunitid = '2090818044' and gpsdate in (select gpsdate from gpsdata where mobileunitid = '2090818044' ORDER BY gpsdate DESC LIMIT 1 ) and gpsstatus='true'
...
Hi,
I'd like to set polymorphism="explicit" property to several hibernate mapping classes. is it possible to override the default implicit value, so that I do not need to set explicit in multiple classes?
<class name="xxxxx" table="XXXXX" polymorphism="explicit">
I am using hibernate mapping xml files (No annotations or JPA) and it w...
Hi guys,
I have a forum-like system where a user has an access group and a post can be accessed by an access group. A post is of a category type, and I'd like to make a list of the category names with the number of posts the user has written in this category in a paranthesis. A user may not have access to all his posts, because one acce...
I'm trying to pull back a list of items that have a specific type of item in a set.
For example:
<class name="Owner" table="OWNER">
<id name="id" column="OWNER_ID" />
<set name="cats" table="OWNER_CATS" lazy="false">
<key column="OWNER_ID" />
<many-to-many class="Cat" />
</set>
<class name="Cat" table="CAT" discriminator-v...
my code
session.createCriteria(Input.class);
DateFormat format =
new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date startDate =
(Date)format.parse("2005-01-01 00:00:00");
Date endDate =
(Date)format.parse("2005-03-03 00:00:00");
crit.add(Expression.between
("inputDate", new Date(startDate.getTime()),
new Date...
hi,
i have one mapping file viz. student.hbm.xml.. i need to generate Student.java from the same. the file is below :-
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping>
<class name="org.hibernate.entity.ClassRoom" table="class_room">
<id name="roomId" column="room_id" type="int"/>
<property name="roomClass" ...
Hi.
I want to implement a class which its fields could change (add new fields) through time. The problem is that I want to give my client this ability to do this himself by just completing a form of what field and which type he wants and then the change will be done automatically!
Does anyone have any idea how can I implement this class...
Hello!
I use Hibernate and I have a datetime in my MySQL database.
Now I want to store the date/time which is a java.util.Date into the database.
So I can write:
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
testObject.setCreationDate(df.parse("2010-06-06 13:20:15"));
But how can I set the current date/time? Bec...