hibernate

I want to insert a file to Oracle using BLOB column type over Hibernate?

I want to save my file on Oracle Instance. I am using Hibernate for data objects. How can I insert files into Oracle Blob. Is there any sample code for this? ...

If you have a db table with a unique column (like "name"), how would you go about switching the names of two rows? (Using Hibernate, but it sounds like a problem across the board)

Let's say you had a table like this /------------ | id | name | |------------| | 1 | foo    | | 2 | bar    | ----------- There is a uniqueness constraint on the 'name' column. How would you set #2's name to foo, and #1's name to bar? I know you could probably just assign temporary names to both then stick in the desired names,...

hibernate collection mapping with list and super entity class

hello good fellas! here i am again in my self learning hibernate and personal experiment project to gain more understanding. Here is the description of my environment: i have a super model entity that all my model inherit from.it has only id property i use the genericDAO pattern found on hibernate web site. Now my problem is that i use ...

ConstraintViolationException VS DataIntegrityViolationException

I am writing a Spring app, and it seems that when I run into database errors, sometimes Hibernate's ConstraintViolationException is thrown and sometimes Spring's DataIntegrityViolationException is thrown. Is there a reason one might be thrown and not the other? Do they mean different things? ...

Design patterns that every developer must know?

What are the design patterns that every developer must know? I'm interested in the context of Java web developers working with Spring & Hibernate. I have often heard that good knowledge in design patterns is essential for working with those frameworks. Can anyone list the specifics? For example, I know that understanding abstract facto...

How do I insert a record with a many-to-one foreign key with grails?

I've been stuck on this for a day now! I'm just getting started with Grails/Groovy. I have two Domain classes with a simple Many-to-one foreign key. Simplified a bit, they are "Company" class Company { String name String city String state String ticker static constraints = { name(unique:true, maxSize:40) ...

How to integrate Hibernate with JBoss 4.2.x server?

Hi there, I need to integrate Hibernate with JBoss 4.2.x server. Any articles to let me know how to do the same are highly appreciated. Thank you Chaitanya ...

How do you pass parameters to Hibernate's subselect tag?

The example at the end of hibernate section 5.1.3 does not show an example on passing parameters. There is no difference between a view and a base table for a Hibernate mapping. This is transparent at the database level, although some DBMS do not support views properly, especially with updates. Sometimes you want to use ...

Hibernate Criteria API - how to order by collection size?

Assuming I have classes User and UserGroup. There is an optional 1-many group to user association and the association is mapped from both sides (the UserGroup side via a property called "members", which is a HashSet, the User side via property "group"). Using the Criteria API, how can I query for all groups, sorted by count of group mem...

How to put 'null' into column using HQL ?

How to build valid HQL string, which is equivalent to UPDATE table SET field = null WHERE .... ...

Using different projection functions in Hibernate criteria API based in Dialect

I want to use a standard deviation projection in a query that Im constructing using the criteria API. I can do something simply like this public class StdDevProjection extends AggregateProjection { public StdDevProjection(String propertyName) { super("stddev", propertyName); } public Type[] getTypes(Criteria criter...

Session handling in Hibernate with Spring

Hello, I am not a beginner in hibernate, but I am a beginner in working with Hibernate in Spring. I read the book Spring in Action. So I wrote a small application to comprehend the examples in the book. Here an extraction of my application. I can give you more, if you want. @Transactional(propagation = Propagation.SUPPORTS, readOnly = ...

How to use ROWLOCK with EJB

I have a problem where I get a deadlock on a MS SQL Server. The same code runs without problems on MySQL. My problem is that I receive a request to delete a job (which is attached to a device), and afterwards I receive a request to create a new job for the same device. Most times this works without any problems, but once in a while the ...

Hibernate transient object exception

Hi all, I am struck with a problem while using hibernate. The situation is : I am creating a container and in that container i am adding 2 components. one component is a newly created component and the other one is already existing in the database.i am getting an exception when i try to save the container. i get transient object...

HQL left join problem: Path expected for join!

Hi, I am new at Hibernate, and I have a question regarding HQL Lejt join. I try to left join 2 tables, patient and provider, and keep getting "Path expected for join! " erroron the second table. Appreciate it if anybody can help on this issue! Here is the mapping of the 2 tables/classes: patient.hbm.xmL: <?xml version="1.0"?> <!DOC...

Hibernate - How to cascade delete on detached objects

I have a hibernate object that gets detached and transferred to a thick java swing client using EJBs. The object is then modified in some way and returned to the server where the server then updates the modified object to the database. Everything works well for properties that change, but I am having a problem on how to delete a many-to-...

Using hibernate/hql to truncate a table?

What is the recommended way to truncate a table using hibernate/hql? I've tried this: Query query = session.createQuery("truncate table MyTable"); query.executeUpdate(); But it didn't work (truncate doesn't seem do be documented anywhere in hql...) ...

Hibernate (with annotations) - how to get started

I'm trying to get started with hibernate, but I can't find any tutorials I understand. I'm trying to create a simple app to get started, but I've really no idea where to get started. I'm pretty advanced with java, although only used eclipse really. So.. where do I configure what DB it uses, and alike? [edit] I'm familiar with the conc...

Hibernate field with custom type changes, but object not marked as 'dirty' for update.

I've got a Hibernate model that uses a custom type to represent boolean fields (ie, model has a 'Boolean' object, but the database writes a 0 or 1 to a TINYINT field. Changing the value of the boolean object from (true to false or false to true) will change the value on the object, but the Hibernate session manager doesn't seem to think...

JPA/Hibernate entityManager.persist(..) makes the entity's collection to become null even though they are saved

I have a PurchaseEntity that has a Set inside. After doing entityManager.persist(purchaseEntity), purchaseEntity itself and purchaseItemEntity's are all saved to DB correctly. But after that entityManager.persist(purchaseEntity) call, purchaseEntity.getItems() returns null. Is this a normal behaviour of Hibernate provided entityManager...