Hi All,
Considering Hibernate 3,
I would like to map a legacy class to a new Db table. (I have to use a legacy model .jar and have to store these objects in a new db)
But my legacy object does not declare a default no arg constructor and i am not able to change the contract because it is part of an API model. (shared by legacy apps). ...
Hi!
We are running JBoss with Hibernate and are having this issue.
When a session bean uses an EntityManager to find an entity, it may already exist in the EntityManager's cache and it's state may be already outdated. If the code uses such an entity to make decisions, it may make wrong decisions that would produce bugs.
Here is an exa...
Does anyone have any experience with creating database agnostic apps in Java, particularly with Hibernate, and simultaneously targeting Oracle and Postgres databases?
In particular I am looking at Oracle Spatial and PostGIS.
We want to create a Java based SOA which can be used with both Oracle Spatial and PostGIS back ends.
I've used Hi...
Hi all,
Our application uses Hibernate with Sql Server 2005.
Being a DBA, I am not an expert of Hibernate yet. And our developers do not understand Sql Server very well, so I need a middle ground to make sense out of this.
I am looking for some info on how Hibernate works with Sql Server 2005. Any best practices or any issues with th...
Say you had a Cat, with Kittens. Then you you did a delete() on a kitten that belongs to a Cat. The Cat object still has a reference to the deleted kitten, until the session closes.
What's an elegant way to avoid this situation?
...
I've configure a few of my objects to be cacheable ( on the mapping file) and from what I can see for this particular object the cache is not working so well.
For other objects I see the hit count increasing on each iteration, but the missed count as 0, whereas for this one I see it misses every single time for the session.
Elements i...
I'm new to Hibernate and am working with an Oracle 10g database. We have columns in our tables that are of type TIMESTAMP WITH TIMEZONE. Hibernate does not seem to support this mapping directly. Is there a standard way to go about this?
Thanks
...
I'd like to integrate existing application with JasperReports. However, when creating report with iReport the wizard is asking me for hibernate.hbm.xml. Since I'm using annotations I simply don't have one. Does iReport work with Hibernate annotations? If so, how can I configure iReport?
...
I'm running Spring and Hibernate's implementation of JPA on Sun's GlassFish Enterprise Server with MySQL.
When I try to delete stuff from the database:
Query q = entityManager.createQuery("DELETE FROM SomeEntity e");
q.executeUpdate();
I get the error:
Caused by: java.sql.SQLException: Error in allocating a connection. Cause: java.l...
Hi!
It seems to me that JBoss reuses entity managers and the underlying hibernate sessions for multiple requests. I have run a test which proves that in some cases the state of an entity may be out-dated even if it is just fetched using em.find().
How can I disable this behaviour and force to clear or throw away used sessions to ensur...
My bidirectional collection mapping seems to only work in one direction. One job will have some number of costs. Each cost is associated with one job. The problem is, when I load a job, the costs collection is empty. However, when I load a cost and navigate from it to the job and then check the costs collection, it is properly filled. Ca...
I'm writing a library that will be used to Hibernate many types of EJBs via JPA. When loading an EJB from JPA, the library needs the datatype of the field(s) annotated with @Id. The @Id may be annotated on a superclass of the EJB. Is there a method in Hibernate or JPA that can get the datatype of @Id?
I'm tempted to use reflection, b...
I have a simple domain class Licensee:
@Entity
@Table(name = "LICENSEE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Licensee implements Serializable, Comparable {
private Integer id;
private String orgName;
/* ... */
private Set<Address> address = new HashSet<Address>();
@Id
@Column(name ...
I'm using hibernate to persist an entity to my database. For the moment it's a derby DB, but I will be moving it over to an oracle DB soon.
in my classname.hbm.xml I have the id defined as such:
<id name="id" type="long">
<column name="ID"/>
<generator class="increment"/>
</id>
How do I set the starting value for the id? ...
Hi. This (should) be a rather simple thing to do, however I am struggling.
I want a table to be generated like this:
id
organizationNumber
name
However, when I look in the database, I see that the ordering is wrong. Does anybody know how I can force hibernate/jpa to generate the table with correct ordering?
desc Organization;
+...
Hello.
I have 2 entities: User and UsersList.
@Entity
@Table(name = "USERS")
public class User {
@Id
@GeneratedValue
@Column(name = "ID")
private Long id;
@ManyToMany(cascade = CascadeType.REMOVE, mappedBy = "users")
private List<UsersList> usersLists = new ArrayList<UsersList>();
public List<UsersList> ge...
I am working on an application which uses hibernate. When the object is returned from hibernate.,it is no longer a pojo.. there is something like cglibenhancer attached to it. because of it i cannot do any operations on it. i need to convert it to a java poja again. for this i am using hibernatebeanreplicator. what it does is that if the...
Hi, i have two tables connected by a foreign key with a one to many relation.
in entity A i have the following :
@org.hibernate.annotations.Cascade( {
org.hibernate.annotations.CascadeType.ALL,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
@OneToMany(mappedBy="monitoredFlight", fetch = FetchType.LAZY)
@OnDelete(action=OnDele...
I have MySql table that has a date field with zeroes ("0000-00-00") as its default value (field cannot be null, I can't change table structure). Hibernate doesn't like zero dates and throws exception during read or save.
I managed to make it read records by setting MySql connection setting "zeroDateTimeBehavior=convertToNull" that conv...
Hi,
See the following class
public class Parent {
private String name;
private int age;
private Date birthDate;
// getters and setters
}
Suppose i have created a parent object as follows
Parent parent = new Parent();
parent.setName("A meaningful name");
parent.setAge(20);
Notice according to code above birth...