hibernate

Good book suggestions for building enterprise software

Enterprise software are built using technologies/softwares/terminologies/APIs such as EJB, JBoss, Seam, Hibernate(JPA), Maven, Eclipse, Spring, JTS, JMS, JNDI etc. I know there are great books out there for each of these individually, however can someone suggest a book or two that covers all (or most of) these topics in lesser detail and...

spring+hibernate set dont allow save

is there any parameter i can set in hibernate so that temporary not allow persist anything but only allow read only (temporary) ? can i set in applicationcontext.xml? ...

Problem with HSQLDB & SequenceGenerator

Hi, I have an entity which has an ID field: @Id @Column(name = "`U##ID_VOIE`") @GeneratedValue(generator = "VOIE_SEQ") private String id; The class has the sequence generator defined as well: @SequenceGenerator(name = "VOIE_SEQ", sequenceName = "VOIE_SEQ") and the Oracle schema has the requisite sequence present. Everything works ...

Map denormalized hibernate

I have a Summary class which contains a list of Qualities. A Quality contains a String name and int value. This data is stored in a denormalized db structure, one table only, for both Summary and Quality. Quality table: id, somefileds, qualityname1, qualityvalue1, qualityname2, qualityvalue2, qualityname3, qualityvalue3 For each quali...

Null transient attributes

Hello, I have a method annotated with @PrePersist annotation but I've seen that when this method is executed all my transient attributes (the attributes with the @Transient annotation) are null. When I debug the applicaion I can see that this transient attributes are not null just before calling the persist() method and when it enters...

Spring Security 3 database authentication with Hibernate

I need to authenticate users from database, Spring Security documents don't tell how to authenticate with hibernate. Is that possible and how can I do that? ...

Hibernate JPA 2.0 CriteriaQuery, subset listing and counting at once

I want to build a method that can both retrieve a count(*) and select * from a criteria query. Using the hibernate criteria API I could easily do this using criteria.setProjection(Projections.rowCount()); , but I recently started using the JPA2.0 Criteria API and am uncertain how to obtain a similar result. Below is a little code frag...

TDD with HSQLDB -- removing foreign keys

I'm using HSQLDB for data layer integration testing, which is great. However, I'm finding that my foreign key constraints are getting in the way of my tests. For example, to test a simple select on one table, I have to insert dummy data into five additional tables. This makes me want to throw things. I have JPA annotations throughout...

Which Java ORM is considered the most performant generally speaking?

Which Java ORM is considered the most performant generally speaking? I realize this could mean less features, but just want an idea. ...

Maven Spring tests fail when run together, but succeed individually (ehcache closed, IllegalTransactionStateException)

We're using Maven/Surefire and Spring/Hibernate transactional tests for a fairly large web application. There are 138 Test* classes, running a total of 1178 tests. A straightforward "mvn test" will generate 82 errors, the nature of which tend to imply a corrupt application context: Many of these: IllegalTransactionStateException: Pre-b...

JPA 2 and Hibernate 3.5.1 MEMBER OF query doesnt work.

I'm trying the following JPQL and it fails misserably: Query query = em.createQuery("SELECT u FROM User u WHERE 'admin' MEMBER OF u.roles"); List users = query.query.getResultList(); I get the following exception: ERROR [main] PARSER.error(454) | <AST>:0:0: unexpected end of subtree java.lang.IllegalArgumentException: org.hibernate....

f:convertDateTime displays wrong Date

Hi! In my Web Application I retrieve data using Hibernate and display it in a RichFaces dataTable. In my MySQL-table there is a field of type "date". When I print this field to the log in my Bean, it shows the correct date from database (e.g. 2010-04-21). But in the rich:dataTable it shows up like this: 4/20/10 So there is a disc...

Including hibernate jar dependencies in ant build

Hi, I'm trying to compile a runnable jar-file for a project that makes use of hibernate. I'm trying to construct an ant build.xml file to streamline my build process, but I'm having troubles with the inclusion of the hibernate3.jar inside the final jar-file. If I run the ant script I manage to include all my library jars, and they are ...

Hibernate find by criteria get single result

Hi, i am experimenting using Hibernate. I am trying to get a User by id this is what i do public User get(DetachedCriteria dc){ List<User> users = getHibernateTemplate().findByCriteria(dc); if(users != null) { return users.get(0); } else return null; } but it fails when the user is not in the database. Co...

Parse HQL to AST Structure and convert AST back to HQL

I have a HQL query: query = select item.itemNumber from items item where item.stock>0 and item.price<100.00 i like to parse this query and convert it into a tree structure: AST queryTree = parse(query); than i like to iterate through the nodes, change some values, and convert the tree back to a string represenation: Iterator<ASTNo...

Why Hibernates ignores the name attribute of the @Column annotation?

Using Hibernate 3.3.1 and Hibernate Annotations 3.4, the database is DB2/400 V6R1, running that on WebSphere 7.0.0.9 I have the following class @Entity public class Ciinvhd implements Serializable { @Id private String ihinse; @Id @Column(name="IHINV#") private BigDecimal ihinv; .... } For reasons I can't fi...

DistinctRootEntityResultTransformer in Hibernate

I'm a little confused about when I wouldn't want to use the DistinctRootEntityResultTransformer as the result transformer for a hibernate criteria. Can anyone shed some light on this? Thanks! Jeremy ...

Hibernate Relationship Mapping/Speed up batch inserts

I have 5 MySQL InnoDB tables: Test,InputInvoice,InputLine,OutputInvoice,OutputLine and each is mapped and functioning in Hibernate. I have played with using StatelessSession/Session, and JDBC batch size. I have removed any generator classes to let MySQL handle the id generation- but it is still performing quite slow. Each of those table...

JPA Cascading Delete: Setting child FK to NULL on a NOT NULL column

I have two tables: t_promo_program and t_promo_program_param. They are represented by the following JPA entities: @Entity @Table(name = "t_promo_program") public class PromoProgram { @Id @Column(name = "promo_program_id") private Long id; @OneToMany(cascade = {CascadeType.REMOVE}) @JoinColumn(name = "promo_program_id") pri...

Hibernate Search + Spring

I'm trying to integrate Hibernate Search with Spring, but I can't seem to index anything. I was able to get Hibernate Search to work without Spring, but I'm having a problem integrating it with Spring. Any help would be much appreciated. Below is my springmvc-servlet.xml: <bean id="transactionManager" class="org.springframework.orm....