I want to generate a unique guid/uuid value for a property which is not a primary key in hibernate. In other words, I want to generate values for an alternate primary key.
How can I do this using Hibernate?
...
Hi,
I have a legacy table that uses a column that holds a date as the natural prmary key to the table. I am trying to map this with hibernate, but for the life of me I can't figure out how to get hibernate to map a single (none-compound) natural key as the Id.
I have it mapped like this:
@Id
@Temporal(TemporalType.TIMESTAMP)
@Column(...
I am using Hibernate 2.6 with hibernate-entitymanager. I am trying to catch and handle situations when 2 transactions conflict on an object. Here is what happens:
Two threads are updating a single object wich has a @Version field. The thread which looses commit race logs StaleObjectStateException on flush. The exception is not thrown, i...
Say I have the following Hibernate-mapped class:
public class ClassA {
@OneToMany(fetch=EAGER)
private List<ClassB> bList;
}
When I read an object of ClassA from a Hibernate session, the bList field is initialized with a PersistentList object, as expected.
I find myself with a requirement where in situations where the li...
Hi,
I have an issue trying to delete using hibernate. When I try to delete I get an exception saying that children exist and there is a FK violation. I want to delete the children also but the delete doesn't seem to be cascading. After about a week of trying to fix this issue I read that I should be using HibernateInterceptor to keep...
i have a forum with 1..n members each having 1..n articles, so this is my mapping:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="true">
<class name="Forum" table=...
Background
I have a table with columns id, imageId, propertyId.
There could be many images associated with a single property and there could be many properties associated with a single image.
imageId - many-to-many - propertyId
I have a list of propertyIds and I want to find out all the images associated with all the propertyIds usi...
We're using Hibernate to load objects that meet certain criteria. If the user decides to view the details on one of the objects, I want to pull up some additional information about the object. One of the "attributes" I'd like to show will require a fairly complex SQL query, but evaluates to a simple boolean.
What's the right way to do...
Is it possible to change the target table for a Hibernate mapping? My use case is that while I get the data from one table, in cases where the data cannot be processed it is stored in a error table for later analysis.
Although it is possible to define entity-names in hibernate mappings, in my opinion it is not appropriate because it re...
I am creating a Flex project using Mate, Blaze DS, Tomcat server. All of that seems to be working. Even my Hibernate calls are working. However they do not seem to be created in the correct way. I am logging in the user with the following block of code in java:
public AbstractUser login(String username, String password){
//Configurati...
How can I get Hibernate (using JPA) to create MySQL InnoDB tables (instead of MyISAM)? I have found solutions that will work when using Hibernate to generate an SQL file to create the tables, but nothing that works "on the fly".
...
I have a multi-threaded, multi-server web application with hibernate and spring managing transactions with AOP. The problem is, I need to maintain in-memory data and keep it current with the state of the database...essentially I'm implementing an in-memory cache.
Now, is there any way to make my in-memory pojos transactional on the same...
I have this query:
sess.createQuery("from Box b join b.items bi order by bi.name").list()
It works fine.
However, I have a hibernate's Collection boxes and want to filter is.
Naive tries:
sess.createFilter(boxes, "join this.items bi order by bi.name").list()
sess.createFilter(boxes, "from this join this.items bi order by bi.name")....
Java Persistence with Hibernate shows lots of examples of how to eagerly fetch associated entities, such as:
Adding @org.hibernate.annotations.BatchSize to the associated class
Adding @org.hibernate.annotations.Fetch to the field that references the associated class
Using the "fetch" keyword in the HQL query, etc...
However in my cas...
Hi,
i am trying to run one jbossESB program to test the data persistence. i have ClassInfo as POJO and corresponding table as user_info but i get this error once i do "ant sendesb"(this is hibernate specific).
13:59:51,225 ERROR [STDERR] org.hibernate.MappingException: Unknown entity: org. jboss.soa.esb.samples.quickstart.helloworl...
I have a problem Hibernate does not update 2nd level cache for a collection of items which are subject of cascade removal.
Details
Assume we have an object Parent which has Parent.myChildren collection of Child objects.
Now we have also object Humans with Humans.myAllHumans collection and all Parent and Child objects are in that collec...
I'd like to have a single configuration file and then when I'm creating a session change the hibernate-configuration->session-factory->connection.connection_string property to what I want it to be programmatically? Is it possible?
UPDATE:
I believe I may be able to do this like this
Configuration cfg = new Configuration();
cfg.Configu...
I've made my entity classes Adress, Road and County. A Road is in a County and an Adress in on a Road. I would like to list all the Adresses in a County. Therefore, in my AdressService I say:
public List<Adress> AllAdresses(County county) {
Adress adress = new Adress();
Road road = new Road();
road.setCounty(county);
adress.setR...
Hi!
I have this class mapped as a entity, lets call it Person. Person has an embedded/component relation to Address. I am having trouble using a Criteria that would return Address objects.
I have tried this:
Criteria.createCriteria(Address.class)
Which does not work. I guess I need to go through the entity but then I would need some...
I have some entity:
public class Album extends GenericAuditedEntity {
@OneToMany(fetch = FetchType.LAZY)
private Set<Item> itemSet = new HashSet<Item>();
}
And when i run HQL like this:
em.createQuery("select a from Album a").getResults()
it produses many SQL queries:
One for select data from Album's table. Smth like thi...