hibernate

its posible use impersonate sql server property on hibernate layer?

i makin an app on java and must to create the same impersonate or context swichtching for sql server property i wonder its posible use impersonate sql server property on hibernate layer? ...

Hibernate bag with multiple elements

I have a bag whose structure looks like this: <bag name="foo" fetch="select" table="table_of_foos"> <key column="foo_ids"/> <many-to-many class="Bar" column="bar_ids"/> </bag> My "table_of_foos" table has two columns: "foo_ids" and "bar_ids", neither of which is unique. I want to add another column to this table that holds som...

Something wrong with Hibernate DB connection pooler c3p0

since last post, did all the changes suggested but this problem still haunts me. Here's the error i get: Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 44,499,102 milliseconds ago. here's my hibernate.cfg.xml <?xml version='1.0' encoding='utf-8'?> <!DOCTYP...

Can hibernate call return a XML data?

Hi, I would like to know if we call a Java class annotated with hibernate classes. Can we get the data from the table in a XML format? browser give data for id =1 --> Servlet --> hibernate class (with some magic xml functionality) --> returns the data in XML format(Can this really happen?) Thanks, Sana. ...

no persistent classes found for query class

Hello friends, I am creating web application using zkoss 5.0.4, Spring 3.0.3, Hibernate 3 and JpA 1.0 with JBOSS 5.1 GA(with jdk support). project compiles fine with JBOSS. But it seems that persitence is not applying for some reason. When I run an application in console it gives following 10:07:35,265 WARN [QuerySplitter] no persis...

Why the value of the foreign key is always zero?

Hi! I try to build some application using hibernate for persistence (my first one). The application has genres and books. The genre class has a set of books. But every book in the set has the idGenre (the foreign key) value 0. I think the mapping is not right. Please tell me where is the mistake. Thanks. Here is the mapping: <hibernat...

Mapping same class relation - continuation

This post is an continuation of this post I have DlUser Class each object of this class may have DLFaceBook class and each object of DlFaceBook can have Friends which are mapped as myFriends. I'm trying to map relation of the same class as many to many relation using bag mapping,composite primary key and static inner class. my code is...

Problem mocking hibernate's SessionFactory using Mockito

Any idea why the following mocking code does not work? org.hibernate.SessionFactory sessionFactory = Mockito.mock(SessionFactory.class); org.hibernate.Session session = Mockito.mock(Session.class); Mockito.when(sessionFactory.getCurrentSession()).thenReturn(session); The thenReturn statement does not compile. "The method thenReturn(Se...

one to many mapping

I have a problem of mapping some scenario into data base.Problem is something like this. There are two entities called Employee(empID,empName) and Task(taskID,taskName). A employee can have ZERO-OR-MORE tasks. A task can have ZERO-OR-ONE employee. What will be the table structure that should I follow.. I'm going to implement this s...

Hibernate Mapping of nested collection in java to mapping table through java annotation?

Problem too specific.closing the same. ...

Hibernate, test if a collection is fully loaded

Hi all, there is a way to test if a collection is already initialized? try-catch only? I have a function work with a lazy collection, and i need to load it only if is not already loaded. Thanks you. ...

Obtain Hibernate's Configuration in Spring

Hello, My project uses Spring, JPA, and Hibernate, so that all EntityManager's are injected by Spring. I need to access persistent classes' meta data such as column lengths and optionality. The only way I know to obtain this information is through Hibernate's Configuration.getClassMapping(String className). In a pure Hibernate project ...

is Hibernate 3.x compatible with Tomcat 5.0.x?

So, I have a godaddy account and I wanted to use it for a small hibernate/spring project... they host java, but they only have the Tomcat 5.0.27 version... would I have to go to a previous version of hibernate or would it work just fine? thanks, Johan ...

DDD Entity and its identifier

I have an entity in my system, which naturally needs an identifier so that it can be uniquely identified. Assuming the database is used for generating the identifier with Hibernate, using the native strategy, then obviously the application code is free of this resposibility of assigning identifiers. Now, can an instance of that entity be...

How to persist a @OneToMany update with hibernate ?

Hi, in my application I've got users which have files. The UserVO has the following mapping: @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "users") public Set<Files> getFiles() { return this.files; } Then I have a HibernateDAO with the following update method: public void update(T vo) { try { ...

Unit-Test, Integration test or problem in design?

Hi, I'm written my first unit-test and I think it is too dependent on other modules and I'm not sure whether it's because: It's a complex test I've actually written an integration test or I have a problem in my design I'll first say that although I have around 4 years of experience in development I never learned, nor were taugh...

Null pointer execption

i am facing null pointer exception in hibernate: org.hibernate.dialect.function.CastFunction.render(CastFunction.java:11) hibernate code is: ("Select date_format(str_to_date(form.dobDate,'%Y%m%d'),'%M (%Y)') as Month"); ...

Can i use a set or List in this example?

public class Student implements java.io.Serializable { private long studentId; private String studentName; private Set<Course> courses = new HashSet<Course>(0); public Student() { } public Student(String studentName) { this.studentName = studentName; } public Student(String studentName, Set<Course> courses) { this.studentName...

hibernate ManyToOne why 2 queries are generated instead of one?

hi, MyTable is a table in my Oracle DB, it has a CMP_ID to join the COMPANIES table. Here is the Java implementation : public class MyTable implements Serializable { ... @ManyToOne(fetch = FetchType.LAZY) @JoinColumns( { @JoinColumn(name = "CMP_ID", referencedColumnName = "CMP_ID", nullable = false) }) @XmlTransient Company company; ....

Hibernate configuration files in another folder than src

Hi! I made a java application using the hibernate framework, with the xml files of hibernate in the src folder. Now, I moved the files in config folder from my project, I changed the SessionFactoryUtil members to: private static File f = new File("config/hibernate.cfg.xml"); private static SessionFactory sessionFactory = new Configu...