hibernate

hibernate connection pool

I can't seem to get hibernate to use c3p0 for connection pooling, it says 12:30:35,038 INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!) 12:30:35,038 INFO DriverManagerConnectionProvider:65 - Hibernate connection pool size: 20 Hibernate Config: <hibernate-configuration> <...

Applying additional aspectj around advice to a spring transactional method.

I have a spring 2.5 + hibernate webapp with transaction annotations and everything works fine. I now want to add a fairly basic aspect with 'around' advice and apply it to my service layer (which is transactional). I am doing this using aspectj annotations and placed <aop:aspectj-autoproxy/> in my spring xml. Spring transactional ...

seperate read and write databases with hibernate

With hibernate, I want to be able to support multiple databases, one for read and one for writes. Is this possible? Is the only way to create 2 separate session objects? ...

Spring + Hibernate bean declaration error

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mappingResources"> <list> <value>product.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <value> hibernate.dialect=org.hibernate.dialect.HSQ...

Spring + Hibernate JPA Question

I'm trying to use Hibernate with JPA/EntityManager to do database activities Right now I'm getting this error and I have no idea what it means. Before I had this code and it works fine. public class JdbcProductDao extends Dao implements ProductDao { /** Logger for this class and subclasses */ protected final Log logger = LogFactory.g...

how do you enforce conditional not null check across sql columns

create table A (id, col_A, col_B, col_C) id = unique id for every row being persisted either col_A or col_B will have a valid value, but both columns will not have a value for each persisted row at the same time. e.g. insert into A (id, col_A, col_C) values (1, "a", "c") insert into A (id, col_B, col_C) values (1, "b", "c") insert i...

How to map both ManyToOne relationship and Join column as writable attributes in Hibernate?

Im working with a legacy database and an application written for Apple WebObjects and migrating that to Hibernate. I'm trying to map a many to one relationship and also its join attribute. But Hibernate gives "Repeated column in mapping" error if i try to do that, unless i make one of it readonly. But the application written in WebOb...

Shared Services on Tomcat 6?

I have been trying to figure out a way to create shared Hibernate session service on Tomcat 6. basically, I need to have this service: 1. to be re-deployable (which exclude the JNDI service); 2. all the web applications can share the same Hibernate sessions (cache). The Tomcat class loading mechanism seems make sharing the db sessions im...

EntityManager refresh problem

I'm getting this error from my EntityManager when I call the refresh function. public void saveProduct(Product product) { entityManager.refresh(product); } I heard this could be a bug with Spring/Hibernate, however I'm not sure how to get around this. Edit: the error is java.lang.IllegalArgumentException: Entity not managed or...

JPA query for DTYPE

I have a single table which is generated from two jpa entities (inheritance). So we have a DTYPE column generated in the database table which has entity name has values. How do I write a jpa query to fetch data for any given entity. i.e DTYPE = 'A'? I just tried using DTYPE in jpa query but as expected I got an error "Could not resolve...

SwarmCache Hibernate configuration

Could anyone hint me how to configure SwarmCache for Hibernate to work in cluster (distributed cache)? Probably there are some other alternatives (please, don't suggest JBoss Cache)? ...

How to execute sql-script file using hibernate?

I gonna write several intergration tests which will test interatcion with db. For each test I need to have a certain snapshot of db. Each db snapshot saved in .sql file. What I want is to execute certain script file in certain test method, like this: @Test public void test_stuff(){ executeScript(finame.sql); ... testing logic ......

Hibernate MappingException Unknown entity: $Proxy2

I'm using Hibernate annotations and have a VERY basic data object: import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.Id; @Entity public class State implements Serializable { /** * */ private static final long serialVersionUID = 1L; @Id private String stateCode; private String stateFullName; ...

Hibernate validator NotEmpty trim issue

It appears that the Hibernate NotEmpty annotation does not result in an error for strings filled with whitespace (" "). Only works for nulls or empty strings (ie: new String()). Is there a workaround/fix for this? ...

EntityManager merge/persist problem

I'm having this strange problem where my merge() or my persist() functions are not being reflected in the database. My JdbcProductDao.java: @Repository("productDao") public class JdbcProductDao implements ProductDao { @PersistenceContext private EntityManager entityManager; public JdbcProductDao(){ } public Produc...

Strange JPA behaviour, initialized field is null

I'm observing a very strange behaviour with an entity class and loading an object of this class whith JPA (hibernate entitymanager 3.3.1.ga). The Class has a (embedded) field, that is initialized in the declaration. The setter of the field implements a null check (i.e. would throw an exception when a null value is set). ... @Entity publ...

Can't stop Hibernate from writing log to console (log4j.properties is ok)

I've already set <property name="show_sql">false</property> & disable all messages in log4j.properties But Hibernate shit to console with all queries & statements. ...

IllegalArgumentException: argument type mismatch in Hibernate

Out of the blue I started getting “IllegalArgumentException: argument type mismatch” in hibernate. The hibernate entity was working for quite some time and svn logs confirm the code to be intact. What might be the case? Here’s part of the exception Jan 16, 2010 10:47:09 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE...

Setting up HProf for Hibernate

How do I setup NhProf for Hibernate? ...

C# put pc to sleep or hibernate

Hi, I want to put my system to either sleep or hibernate, two different options. How would I do this with API's, I don't really want to use Process, and that doesn't allow me to choose what method I want for this action. Thanks. ...