I am using Hibernate by implementing "Open Session in view" pattern?It opens a new connection per request. Is there any way to use the existing connection? Is my understanding correct? May be i miss something during implementation which cause opening of new connection?
...
I have a db in production where all of my tables are using utf8 / utf8_general_ci encoding. This is basically working fine except in one scenario.
What happens is that ??? are being returned for some characters (Chinese, etc); however, they are also returned correctly for the same table but via a different criteria.
I've double checked...
I recently had a rather strange phenomenon. Had to obtain a count that included joins over multiple tables with different WHERE conditions. I implemented the query first with the criteria API of hibernate. It correctly created the requested prepared SQL statement but was rather slow. Re-implemented then the entire query using HQL. Was ra...
I have a JPA annotated class which contains a collection like so:
@Entity
public class Employee {
@Id
private int id;
@Basic
private String name;
@OneToMany
@JoinTable(name = "ORG", joinColumns = @JoinColumn(name="MINION"),
inverseJoinColumns = @JoinColumn(name="EMP"))
private List<Employee> minions = ...
For example, I have two entities: Employee and Address. Of these enitities, Employee has a foreign key AddressID references the ID column on Address. In the Java domain objects, Hibernate nicely wraps the forgein key integer field with a Address object field. But now, how could I query the Employee with a certain AddressID?
I have trie...
I have two objects:
public class ParentObject {
// some basic bean info
}
public class ChildObject extends ParentObject {
// more bean info
}
Each of these tables corresponds to a differnet table in a database. I am using Hibernate to query the ChildObject, which will in turn populate the parent objects values.
I have defined my m...
I have two entities that have a many-to-many relationship; they are mapped with annotations @ManyToMany and @JoinTable. In the database join table I also have "order" column which would indicate in which order B entities are listed in A. (The ordering of Bs is specific for each A).
How can I get Hibernate to order list according to the ...
What is best practice for using Database Transactions with Seam when not using EJBs - ie. when deploying Seam as a WAR?
By default Seam JavaBeans support Transactions. I can annotate a method with @Transactional and that will ensure that a transaction is required. Or I can use @Transactional(NEVER) or @Transactional(MANDATORY). What I c...
I'm using Hibernate EntityManager, and am experiencing a weird slowdown in my Hibernate queries. Take a look at this code:
public void testQuerySpeed() {
for(int i = 0; i < 1000; i++) {
em.createNativeQuery("SELECT 1").getResultList();
}
}
This runs in about 750ms on my machine. Not blazing fast considering it's just s...
Hi,
I have a problem with some queries which get duplicated at the database automatically after 80 seconds. This colapses the database because each thread duplicates after 80 seconds if it has not received any information. I really don't know what to do...
This is the pool I have defined:
<property name="c3p0.acquire_increment">1...
Below is my entity id's definition and I am using hibernate as the jpa implemention
@Id
@TableGenerator(name="customer_generator",
table="system_sequences",pkColumnName="sequence_name",
valueColumnName="sequence_next_hi_value",initialValue=1,allocationSize=20)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "customer_ge...
I have Item objects which have a collection of attributes defined as a map. Now I want to retrieve all objects which have a specific attribute (by name, locale and value)
An expecert of the Item mapping:
<map table="ITEM_ATTRIBUTES" name="attributes">
<key column="item_id" foreign-key="fk_itmr_attrbts_itmrs"/>
<composite-index clas...
I have written a very basic and naive oneToMany relationship between a ChatComponent and its Chat Messages like this:
@OneToMany
List<ChatMessage> chatMessages;
This basically works, i.e., doing something like:
ChatMessage chatMessage = vo.toDomainObject();
chatMessage.setDate(new Date());
//Add the message to the chat component
em.g...
I'm try to insert or update db record with following code:
Category category = new Category();
category.setName('catName');
category.setId(1L);
categoryDao.saveOrUpdate(category);
When there is a category with id=1 already in database everything works. But if there is no
record with id=1 I got following exception:
org.hibernate.St...
I have to map a lecagy database for read-only purposes that contains the following structure:
Table MAIN:
id productId productType
Table PRODUCT_A:
id description_a
Table PRODUCT_B:
id description_b
Table PRODUCT_C:
id description_c
Depending on the value in column productTyp, the productId refers either to the PRODUCT_A,PRODUC...
I am setting up Hibernate Caching and want to cache certain entities in different regions. For example, some entities can be "stale" for up to 5 minutes, some for an hour, and some (like lookups) won't change for weeks. To facilitate easy config of regions in my code, I'm trying the following:
I created an annotation named @LookupCache ...
I'm trying to write a query in NHibernate. I don't really care if I use the Criteria API or HQL, I just can't figure out how to write the query.
Here's my model:
public class LogEntry { public DateTime TimeCreated { get; set; } }
public class Note : LogEntry { public string Content { get; set; } }
public class Workflow { public IList<...
I've got a project which requires both Jersey and Hibernate. Problem is they both use incompatible versions of a Jar file (asm.jar) under the covers. I've looked around Google and it appears that it's possible to get Hibernate to use another facility called Javassist, but when I try to follow the instructions it falls flat. I still get ...
Suppose there are three tables:
Table A (ID, NAME)
Table B (ID, NAME)
Table A-B (A_ID, B_ID, Boolean_Property)
and Table A and B are modeled by classes A and B as follows:
public class A {
private long id;
private String name;
// All the B's that belong to A where the boolean property is True
Set<B> trueBSet;
//...
Hello there.
I am using Hibernate 3.2.5 and Hibernate Annotations 3.3.1.GA as the JPA provider in a data loading application. I have configured Hibernate to use C3P0 for connection pooling.
My database is: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
As there is no built in hibernate dialect for 11g, ...