Tagged Questions
24
votes
3answers
72k views
Hibernate: Automatically creating/updating the db tables based on entity classes
I have the following entity class (in Groovy):
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
@Entity
...
23
votes
9answers
11k views
Is there a more efficient way of making pagination in Hibernate than executing select and count queries?
Usually pagination queries look like this. Is there a better way instead of making two almost equal methods, one of which executing "select *..." and the other one "count *..."?
public ...
19
votes
4answers
14k views
Anything similar to Hibernate in PHP?
I am a Java programmer and was working on a project using Hibernate and Struts for some time.
Now For my new project, I am working on PHP and Mysql (learning PHP).
Is there any technology which is ...
17
votes
9answers
21k views
Using Hibernate's ScrollableResults to slowly read 90 million records
I simply need to read each row in a table in my MySQL database using Hibernate and write a file based on it. But there are 90 million rows and they are pretty big. So it seemed like the following ...
15
votes
1answer
582 views
Weird NPE on BatchingBatcher “JDBC driver did not return the expected number of row counts”
I'm running a spring/hibernate java app on tomcat and I'm seeing this funky error on update:
JDBC driver did not return the expected number of row counts
Caused by: java.lang.NullPointerException
...
12
votes
5answers
14k views
Hibernate, C3P0, Mysql — Broken Pipe
MySQL seems to have an 8 hour time out on its connections. I'm running multiple WARs in Tomcat utilizing Hibernate for ORM. After 8 hours (i.e. overnight), I get broken pipes when it picks up an ...
12
votes
2answers
1k views
Spring app losing connection to MySql after 8 hours. How to properly configure?
I've got a Spring app that I believe uses DBCP connection pooling to connect to a MySql database. I say believe because this isn't an area I'm very strong in and I'm not positive if everything is set ...
11
votes
5answers
17k views
Hibernate not respecting MySQL auto_increment primary key field
I am trying to learn how Hibernate works, and I am running into an almost unacceptable learning curve. I can't see how to get Hibernate to respect the auto_increment policy for my objects. Instead, it ...
11
votes
3answers
10k views
Spring, Hibernate, Blob lazy loading
Dear Sirs,
I need help with lazy blob loading in Hibernate.
I have in my web application these servers and frameworks: MySQL, Tomcat, Spring and Hibernate.
The part of database config.
<bean ...
11
votes
2answers
3k views
Can Hibernate work with MySQL's “ON DUPLICATE KEY UPDATE” syntax?
MySQL supports an "INSERT ... ON DUPLICATE KEY UPDATE ..." syntax that allows you to "blindly" insert into the database, and fall back to updating the existing record if one exists.
This is helpful ...
11
votes
2answers
12k views
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed
I built an application and deployed locally ... and it was working perfectly. I deployed it on a remote server and started getting the exception mentioned in the subject line. It's not because of any ...
10
votes
5answers
22k views
Enum in Hibernate, persisting as an enum
In my MySQL database, there's the column "gender enum('male','female')"
I've created my enum "com.mydomain.myapp.enums.Gender", and in my Person entity I'm defined "Gender gender".
Now I'd want to ...
10
votes
2answers
9k views
Hibernate JPA, MySQL and TinyInt(1) for Boolean instead of bit or char
Here is my JPA2 / Hibernate definition:
Code:
@Column(nullable = false)
private boolean enabled;
In MySql this column is resolved to a bit(1) datatype - which does not work for me. For legacy ...
10
votes
1answer
510 views
JPA2 Criteria API .as(String.class) casting to char(1) - How do I work around this?
Using the criteria api, I have a query which does something like:
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<SourcePath> pathQuery = ...
10
votes
3answers
11k views
Reproduce com.mysql.jdbc.exceptions.jdbc4.CommunicationsException with a setup of Spring, hibernate and C3P0
I got this error from the production code:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
The last packet successfully received
from the server was36940 seconds
ago.The last packet ...