hibernate

How to automatically set date_created using spring aop

Hello Gurus !!! i've been working on a project in java+maven+spring+hibernate and i wanted to automatically assign the current date to the POJOs before the calling of saveorupdate. i wouldn't mind creating new Date() for all the date_created of all the classes but they are just plenty. I've just discovered that spring aop is good at tho...

Hibernate C3p0 MySQL - Getting frequent CommunicationsException

My Java App communicates to MySQL using Hibernate and C3p0 libraries. I am getting following exception almost every day. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException MESSAGE: Communications link failure The last packet successfully received from the server was 32,088,839 milliseconds ago. The last packet sent successfully ...

Composite ids between multiple tables in Hibernate

Hi, I'm pretty new with Hibernate, and I'm facing some trouble working with composite ids and foreing keys, I just want to make this work: ======= ======= Table A Table B ======= ======= atr1 PK atr1 FK(Table A, atr1) PK atr2 PK atr2 FK(Table A, atr2) PK atr3 atr3 FK(Table C, atrN) PK atr4 And the re...

GWT and Hibernate NoClassDefFoundError

Hi, When i try to make an RPC call to the server i get the following error message ** WebModule[/ProjectName]Exception while dispatching incoming RPC call java.lang.NoClassDefFoundError: net/sf/cglib/proxy/Enhancer** Is this any classpath issue?or do i need to include any lib file or something in my project? I tried searching for a s...

Hibernate Many-to-Many Criteria Projection

EDIT> i am at a dead end... so i can continue looking for the main reason .. Please tell me how to make a simple criteria for many to many relationships which has more than one eq restrictions, for an example, how to get the person speaking eng & german in the example shown here... My situation is like this i have two classes person and...

Using longblob in hibernate

I'm new to the hibernate world and I am using it to map a table that stores files of all types. I am however recieving a very strange error: javax.servlet.ServletException: java.lang.ClassCastException: [B cannot be cast to java.sql.Blob I have mapped my MySql LONGBLOB column has: <property name="fileData" type="blob" .../> and <prope...

How to find BOTH threads of a deadlock ?

Hi guys, We're having the classic spring/hibernate/mysql stack running in Tomcat 5.5. Once in a while we're getting a deadlock when the attempt times out to lock a table row. Some kind of deadlock exception is thrown. The exception is clear and the stack trace indicate what went wrong. But it doesn't show the other thread which is hold...

tapestry-hibernate and 2 databases

I have a Tapestry5.1 app using tapestry-hibernate which now needs to connect to a 2nd (separate, not redundant or load balanced) database. I've read that you can do this in hibernate by creating 2 separate session factories. I'm not sure how to configure this in tapestry-hibernate though. Any ideas? ...

No Hibernate Session bound to thread

I am using Spring MVC and Hibernate. I want to use the OpenSessionInViewFilter to allow lazy loading to work properly in the view layer. The OpenSessionInViewFilter requires a root application context so i added a ContextLoaderListener and moved my non view related configuration files to it from the DispatcherServlet. The app-config.x...

NHibernate mapping with forking inheritance model

I'm just starting out with NHibernate and am trying to do a mapping for my model. (this is a model-first, TDD approach, just creating the database now) My Class hierachy is something like : I'm trying to work out how to map this now using a mapping xml file? This is my table and what I want them to map to QuestionId - Int - [Quest...

entitymanager.merge does not seem to commit

I have an application using Tomcat/Spring 3/JPA/Hibernate but my merges do not commit to datbase. This is the configuration: spring-conf.xml: <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jd...

Mysql to Mysql - Hibernate replication using db40/drs?

Hello, I would like to do Mysql to Mysql replication using drs. Is it possible to do the same without storing data in db4o? I just want to use drs replication using Hibernate. Any positive/negative experience with drs? ...

Perform daily action at a specific time based on user's local time zone

My Java application needs to send an email out to all users once per day. I'd like to deliver it at approximately 2AM based on each user's local time. So a user in New York would get the message at 2AM America/New_York time. A user in Los Angeles would get the message at 2AM America/Los_Angeles time. My mailing process would run once eac...

Hibernate - Custom insert into database

Hi, I write this post to know if someone knows how to do this: I want to do this insert: INSERT INTO TABLA (CAMPO1, CAMPO2) VALUES (?, crypt(?,'cdp')) Crypt is a funtion stored in my database and the insert I would want to do it in my code. Actually when I want to insert something in the database I use: getHibernateTemplate().persis...

Tell hibernate hbm2ddl not create individual table

Is there a way to tell hibernate's hbm2ddl to not create specific table but still have the model be recognized by Hibernate. The thing is that the model map to a view and I want to have an in-memory database (empty on startup and deleted on termination) for testing, hence, having 2 sets of mapping is out of the question. ...

Hibernate/JPA + Derby - SELECT statement has too many items in GROUP BY, ORDER BY or select list

I use Hibernate for JPA DB mapping with Derby DB. For a complex object structure I am getting "org.apache.derby.client.am.SqlException: SELECT statement has too many items in GROUP BY, ORDER BY or select list": org.apache.derby.client.am.SqlException: SELECT statement has too many items in GROUP BY, ORDER BY or select list. org....

Sharing a Spring transaction between hibernate & JdbcTemplate within a AbstractTransactionalTestNGSpringContextTests

I'm running a test within a subclass of AbstractTransactionalTestNGSpringContextTests, where I execute tests over a partial Spring context. Each test runs within a transaction, which is rolled back at the end to leave the database unchanged. One test writes to the database through Hibernate, while another reads from the same database us...

Is it possible to use different inheritance strategy for subclasses?

I currently have a mapping problem and no idea how to solve it. Here is what we currently have. AbstractEntity is a @MappedSuperclass ExtendedEntity is an abstract @Entity extending AbstractEntity with InheritanceType.TABLE_PER_CLASS Proposal is a subclass of ExtendedEntity that has been stored in a single table so far. Now I want to...

Mapping a composite key with incremented column in Hibernate

I have a PROPERTY table whose primary key is defined as (REF_1_ID, PROPERTY_ID, PROPERTY_IDX) , where PROPERTY_IDX ranges from 0 to n for the same values of (REF_1_ID, PROPERTY_ID) . I would like to leave it to Hibernate to mange the value of PROPERTY_IDX, so that I can set it to null for new objects and have it populated on save. Wh...

whats wrong with this simple HQL syntax?

Hi i am trying to execute this simple HQL query to get a list of files from my database using: private static final String SQL_GET_FILE_LIST = "select filename, size, id, type from fileobject"; @Override public List<FileObject> getFileList(String type) { // TODO Auto-generated method stub List<FileObject> files = hbTemplate.fin...