hibernate

JPA or Hibernate - Joining tables on columns of different types

Is there a way to tell Hibernate to wrap a column in a to_char when using it to join to another table or conversely convert a NUMBER to a VARCHAR? I have a situation where I have a table which contains a generic key column of type VARCHAR which stores the Id of another table which is a Number. I am getting a SQL exception when Hibernate ...

How to get the results with count 0 too with Hibernate?

I am using the Projections.rowCount() function on Hibernate, but it will only return the counts greater than 0. I need to get the list with the 0 count too. This is the function supposed to give me the count but it only returns counts greater than 1. public List<Object[]> getCuentaPorEnlotar() { DetachedCriteria criteria = casosEst...

[hibernate] criteria.list() return rendundant records if fetchtype is EAGER

Hi all, look this code: // In A.java class @OneToMany(mappedBy="a", fetch=FetchType.EAGER) @Cascade(CascadeType.SAVE_UPDATE) private List<B> bList; // In B.java class @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="id_a") @Cascade(CascadeType.SAVE_UPDATE) private A a; And this is my record in DB tables. // Table A | ID |...

Hibernate: send entity through TCP lose persistentbag(or not update it)

Hi all, i have an entity with a @OneToMany relationship: @OneToMany(mappedBy="a", fetch=FetchType.EAGER) @Cascade(CascadeType.SAVE_UPDATE) private List<B> bList; Im writing a server/multiclient app: a client send A to server and server resend A to other clients. So, client1 send A with bList that has size 3. Server receive A entity, b...

Search for a property in Hibernate after aplying a function.

In my db I store telephone numbers of things as input by the user (I want to let user decide how he format their phone number) when users search for a phone number they most likely wont format the number in a way that I can just compare the two strings. Even 'like' wont do the trick since maybe the number has parenthesis or some other u...

Hibernate | Identifier Generation Exception

I'm getting an exception when I try to save some data through hibernate persistence layer, the exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): hbm.Employee public void saveEmployee(Employee empValue) { Session session = null; Transaction t...

[hibernate] Can i send an @entity through TCP java socket?

Hi all, all my test fails ... so is possible send an @entity using a TCP socket? UPDATE Problem is related at this post http://stackoverflow.com/questions/3097269/hibernate-send-entity-through-tcp-lose-persistentbagor-not-update-it Thanks. ...

Java swing application save custom file format

Hello, i'am writing some swing applications(not rich clients, running standalone) with a lot of domain models. Those are Java Beans, bound to the UI via presentation models. Now i need to save all the domain data in some kind of a custom project file format. The software will go through many versions, in wich the domain models always ...

Should I use static of non-static sessions?

I've recently taken on the database/hibernate side of our project and am having terrible trouble understanding some fundamentals of our design regarding the use of managed sessions. We have a util class containing a static session that is only initialised once. Retrieval of the session is used by every DAO in the system via a static met...

about j2ee, spring and hibernate

Basically i want to learn this technology. I already know J2SE. My question is, where is the good start to learn Spring and Hibernate? Is the book Head First JSP and Servlets good or what? ...

Hibernate, SQL and recursive associations

My database has two tables, "question" and "field". Questions may have many fields, and fields may have many fields. It's a tree with a special root node. I want to use them with hibernate (currently potgresql) - so it should be straightforward and simple to use it from java. What is the best solution to this? add question_parent_id ...

Hibernate mysql innodb

Hi! I wanted to force hibernate to use innodb. So, i changed the "hibernate.dialect" in order to have innodb, but i can connect to mysql, but when i do some transactions i have the following error: org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.Rol...

Is there any difference in performance between these two instructions?

i have the following criteria specification and wanted to know if there is any difference in the performance or the memory usage of them. 1st way: criteria.add(Restrictions.eq("case.estadoOperativo", Caso.EstadoOperativo.COMPLETADO)) .add(Restrictions.eq("case.estadoAdministrativo", Caso.EstadoAdministrativo.TARIFICADO)); 2nd ...

Spring or Struts web based tool to list content of database tables

Hi, Is there an open source web based tool preferably based on Spring(or struts) and Hibernate that will list the contents of a database table? I can write one but there are hundreds of tables so im wondering if i can use an existing open source tool that will list the contents of the table based on what i select. Basically all i wan...

Hibernate DAO method parameters

Which one do you prefer and why? Reservation[] find(User user, Show show) Reservation[] find(long userId, long showId) Thanks ...

Persisting application settings with Hibernate

What is the best/prettiest/most flexible way of storing application settings with Hibernate? Is a single row table the way to go, or is there a better way? The ability to store extra settings in the same place/table, but outside of the application domain would be nice. I've experimented with a Key/Value table, for example: Key | ...

Oracle and HIbernate, db sequence generator issues.

I have the following entity (getters and setters ommited)... @Entity @Table(name = "TBL_PROJECT_RUN") public class ProjectRunEntity { @Id @Column(name = "ID") @GeneratedValue(generator = "StakeholdersSequence") @SequenceGenerator(name = "StakeholdersSequence", sequenceName = "STAKEHOLDERS_UPDATE_SEQ", allocationSize = 1...

hibernate querry for joins without foreignkey constraints

i can run the following querry in sql the table having primary keys only,i did not make any foreign key constraints.the querry was execute and gives the results.can i do this in hibernate? /* select employee_evaluators.employee_id as evaEmpId,evaluator_id as evaId, employees.employee_name,customer.customer_name from employee_evaluators ...

Hibernate | Data Exception

I'm getting an exception when I try to save a batch data (using hibernate as the persistence layer), Here's the exception: org.hibernate.exception.DataException: could not insert: [hbm.Employee] here's my business logic to save the data: (DusinessDAO.class) public void saveEmployee(Employee employee) { Session session = nul...

Hibernate and JPA, what to use, where?

Could someone please explain to me what the main differences are between JPA and Hibernate? Where to use Hibernate ? Where to use JPA? Why not entity bean? ...