equal « Data Type « JPA Q&A





1. commandline equivalent to reverse engineering in Hibernate tools?    stackoverflow.com

Is there a relatively simple way to reverse engineer a database from the command line and generate Hibernate artifacts based on the database? the only info I've been able to find ...

2. What is the equivalent of JPA in .NET?    stackoverflow.com

I think JPA is nice and convenient ( not to mention standardising, as we used to have every individual programmer doing his/her own thing with a jdbc connection). I would like to ...

3. Does JPA have an equivalent to Hibernate SQLQuery.addScalar()?    stackoverflow.com

My old Hibernate-only code uses something like

session.createSQLQuery("SELECT * FROM CATS")
.addScalar("ID", Hibernate.LONG)
.addScalar("NAME", Hibernate.STRING)
.addScalar("BIRTHDATE", Hibernate.DATE)
In the new project we use Hibernate EntityManager (the JPA implementation). Is there an equivalent to those calls to ...

4. Hibernate and equals()    stackoverflow.com

I might've read somewhere that:

  1. Hibernate does not write to the database if an entity to be saved has no changes to it persistent state in the database.
  2. Hibernate uses an entity's equals() ...

5. What is the Hibernate equivalent of JDO makeTransient    stackoverflow.com

I am porting my Dao layer from KodoJDO to Hibernate. I am keeping my menus in the database and based on a user's entitlements I prune a local copy to display only ...

6. OpenJPA registerColumnType() equivalent    stackoverflow.com

With regards to this SO question ( JPA/Hibernate DDL generation; CHAR vs. VARCHAR ), I was wondering whether there was any functional equivalent in OpenJPA 2.0.1 to this method found ...

7. JPA 2: Change @NamedNativeQuery to CriteriaBuilder equivalent    stackoverflow.com

Is it possible to change this @NamedQuery query:

SELECT @rownum:=@rownum+1 'no', m.title, m.author, REPLACE(SUBSTRING_INDEX(m.content, ' ', 20), '<br>', ' '), m.viewed, m.hashid FROM book m, (SELECT @rownum:=0) r WHERE m.lang = ?1 ...

8. TypedQuery equivalent for JPA 1.0    stackoverflow.com

I am quite new to JPA and I am using Apress JPA2 text book to learn it. I was trying to do the first example from the book. This following line ...

9. Problem with equals() method in Hibernate    stackoverflow.com

I am developing an application in Hibernate where I have model classes like these:

public class Employee
{
    private int ID;
    private String name;
    ...





10. contains() and equals() in Hibernate Sets    coderanch.com

Hello all - I have a one-to-many association between roles and users. I have created/tested the ORM mappings using Hibernate and successfully persisted instances of both classes. Below are simplified definitions of the classes: /** * A role defines a unique set of users. */ public class Role{ private int id; private String name; private Set users; public void setId(int id){...} ...

13. Equivalent jpa statement?    java.net

14. equals() method (Beat a dead horse)    forum.hibernate.org

Ok, I have searched through tons of posts dating back to 2004 on the issue of overriding the .equals() method. I was wondering what the best way to override the .equals() method is today? My situation is that my entity classes are at times proxy instances so I know that I can't use the normal "if (getClass() != obj.getClass())" method since ...

15. How do you implement the equals method in a tree?    forum.hibernate.org

Let's say you have classes in a tree like below: (the getters and setters have been omitted.) Code: class Country { String code; Set provinces; // of type Province } class Province { String code; Set cities; // of type City } class City { String code; } Seems like ...

16. Proxies and equals()    forum.hibernate.org

I see really-really weird behavior of my code after I started using proxies. Yes, I have read FAQ and know I should use accessors instead of direct access to the members. But... I just want to understand HOW THIS CAN BE POSSIBLE! public class Company { ... public void test(Company other) { System.err.println("---TEST---"); System.err.println("this==other => " + (this == other)); System.err.println("this=" ...





17. equals implementation with proxies    forum.hibernate.org

I have a root persistent class with a default implementation of the equals(...) method. It assumes that two persistent objects are equals if: - they have the same identifier value - AND share the same class Code: public boolean equals(Object obj) { Persistent other = (Persistent) obj; boolean sameId = this.getId().equals( other.getId() ); ...

18. [Performing equivalent to a triggerOnSave]    forum.hibernate.org

19. Does hibernate have an equivalent option to this ibatis feat    forum.hibernate.org

The criteria api mostly does what I am looking for. However, I believe there is a bug. Give the function below crit.add(Expression.eq("model.description", map.get("modelDesc"))); should be the same as modelCriteria = crit.createCriteria("model"); modelCriteria.add(Expression.eq("description", map.get("modelDesc"))); However, the first method throws a QueryException ("could not resolve property") . According to page 218 of the Hibernate in action(sample chapter), I can dereference child objects with ...

20. BLOB equals in HQL    forum.hibernate.org

ParameterMap pm = new ParameterMap(); pm.put(DataConstants.SAVED_ITEM_ID, new Long(itemId)); String select = "SELECT s_item.link " + "FROM SavedItem s_item " + "WHERE s_item.link.lnkRequest = ...

21. How to think about equals()    forum.hibernate.org

Thinking about exactly how to write the equals function for hibernate based classes.... I read somewhere to think of it kind of like a weaker database primary key. So for example, if the object was a Person, then I might make equals() be true if both the firstName and lastName properties were equal. In a way I am saying that this ...

22. Is lazy="true" equal to proxy="interface net.    forum.hibernate.org

23. Comparing Proxied objects with .equals    forum.hibernate.org

I have defined an interface and implementation class. The interface has getters and setters for two properties: id, name The implementation class has the implementation, and overrides the equals, and hashCode method. I am trying to implement a routine which will take an arbitrary loaded object, and use a completely seperate session to load a second instance of the object (I ...

24. Can not remove object from Set (equals & hash are correc    forum.hibernate.org

Hibernate version: 2.1.6 Hello all. In my application I over-ride equals & hashCode properly. When I add instances of these classes to Vector's and call remove(), equals() gets called and the object is removed as it should be (if equals == true). However, when I call remove() on a persistable set, equals() is never called, and the object is not removed. ...

25. strange behavior in equal method    forum.hibernate.org

I have a many-to-many association resolved in 1 one-to-many association and the linking class as 2 many-to-one association (i don't need the association from the second class to the linknig class..maybe is this the problem?). I mapped the collection with cascade="all-delete-all-orphan" but when i remove an element it is not removed. Instead it works well with insert. So I checked the ...

26. Why equals method doens't work?    forum.hibernate.org

This is the test code: Course course = courseService.load(new Long(1)); Quiz quiz = courseService.loadQuizById(new Long(8)); Quiz q = (Quiz)course.getQuizs().iterator().next(); if(quiz.equals(q)) { System.out.println("TRUEEEEEEEEE"); } else { System.out.println("FALSEEEE"); } I stored only a course object and only a quiz object in the db. Anyway I assure you that "quiz" and "q" are equals. I won't give the xml because i don't think the ...

27. help w/ equals(), collns with cglib proxies    forum.hibernate.org

Hibernate version: 3.0b4 [n]mapping (partial)[/b]: .... omitted properties ... .... omitted properties ... ... other types ...

28. Hibernate trigger equivalent?    forum.hibernate.org

I'm sure this is straightforward but can't find the answer. I have a whole bunch of business objects (POJOs) all descended from a base BusinessObject class. I would like a method in this class to be run every time an object is about to be persisted to the database. Can this be done? The method is just a timestamping one (setting ...

30. Overiding equals() proxy gotcha    forum.hibernate.org

31. equals() needed to use get() methods    forum.hibernate.org

Thank you Max, for your reply. I ask because I tried using both CodeSugar and Common4E plugins for Eclipse, to help me generate the equals and hashCode methods. They both compare fields - which caused me some days of frustrated debugging to find the origin for some weird bugs... (BTW , .getClass() comparison doesn't work as well... Same reason I guess) ...

32. CGLIB proxy and equals method    forum.hibernate.org

/** * @see java.lang.Object#equals(Object) */ public boolean equals(Object object) { if (object == this) { return true; } if (!(object instanceof ProviderType)) { return ...

33. Does Hibernate equal to ejb?    forum.hibernate.org

Is Hibernate 3 the same as EJB 3's persistence spec or EJB 2.x entity beans? I assume that is the question. -------- Well, if you look at it from the 50,000 foot view that these are mechanisms to help you store and retrieve info with a relational database then yes, they are the exact same thing. -------- If you look at ...

34. Broken equals() implementations    forum.hibernate.org

I'm having trouble with the equals() methods of my persistent object, shich seems to be a result of CGLIB enhancement. I'm not sure how to tell Hibernate to produce enhanced classes that don't break my code... Here's a simplified example: class Foo { private String fooProp; public String getFooProp() ... public boolean equals(Object other) { if (other == null) return false; ...

35. Hibernate 2.x equivalent to Hinernate 3.x Method...    forum.hibernate.org

... SQLQuery#addScalar(String,Type) Hi, I use a native sql query in Hibernate 2.x. The result of the following select: select tmp.scalar, {businessobj.*} from businessobject businessobj ... join tmptable tmp on tmp.x = ... ... where ... should be a List with a Long reference in Object[0] and a BusinessObject reference in Object[1]. The select without the scalar is easy. But I dont ...

36. identity equal?    forum.hibernate.org

hi I have Person and Address classes. There is a unidirectional relationship between these two. When my program starts i get all the persons from the database (also all the addresses that have a relation with some person) but some other time i need all the addersses, so i check all the addresses form database. since i get them in different ...

37. Equivalent of JDOHelper ?    forum.hibernate.org

Hi, we're migrating a large application from JDO 1 to hibernate 3 and there is still a point we can't easily "translate" from the existing code. Using JDO, we could use JDOHelper.isPersistent, JDOHelper.isNew, JDOHelper.isDeleted, ... to get the status of a persistent enity. With Hibernate, it seems like the internal status should be reachable via ((SessionImplementor)session).getPersistenceContext().getEntry(...).getStatus(). But this is non intened ...

38. HQL LIMIT equivalent    forum.hibernate.org

39. Restrictions.eq() doesn't look for equals()?!    forum.hibernate.org

@Table( name="AUTHORITIES", uniqueConstraints = @UniqueConstraint(columnNames={"SERVER_NAME","DOMAIN_LABEL"}) ) public class Authority { ... @Id(generate = GeneratorType.IDENTITY) @Column(name ...

40. Hibernate equivalent to Toplink's DataReadQuery    forum.hibernate.org

Hi, I'm experienced with Toplink, but need to transfer a Toplink technique to Hibernate for some application integration requirements we have. In Toplink a DataReadQuery is purely a SQL query result, i.e. not really object relational mapping. I can execute a query and then iterate over the result rows, and for each row iterate over the result columns. This is quite ...

41. Hibernate's equivalent to TopLink's registerObject()    forum.hibernate.org

Hello. I am migrating one of my project's code from TopLink to Hibernate. Currently I have problem finding replacement to TopLink's UnitOfWork.registerObject() method. UnitOfWork.registerObject() is used to register a transient object to the session and the object will be saved to database at commit time. All modification to the object after calling this method and before commit the transaction will also ...

42. contains() and equals() in Hibernate Sets    forum.hibernate.org

Hello all - I have a one-to-many association between roles and users. I have created/tested the ORM mappings using Hibernate and successfully persisted instances of both classes. Below are simplified definitions of the classes: Code: /** * A role defines a unique set of users. */ public class Role{ private int id; private String name; private Set users; ...

43. Java identity implementation of equals()    forum.hibernate.org

44. Equals method not working    forum.hibernate.org

Hibernate version: 3.2 For background, I am using a long session pattern. Well, I have a class Item that has just an id and a name. I wrote an equals method that just compares the name, since that is the business key. The method works fine for when it is transiet. However if I use a DAO to retrieve the same ...

45. Date/Timestamp problem with Java: equals fails, workarounds?    forum.hibernate.org

The dateEquals option is the best of what you suggest. Even better would be to correctly implement Project.equals to take advantage of your new knowledge, gleaned from gavin's entirely correct statement at the end of the thread you mentioned: gavin wrote: Note that no self-respecting code should EVER call equals on a Timestamp. Its almost as bad as for Float. This ...

47. BasicLazyInitializer "equals" bug    forum.hibernate.org

The initializer checks the flag "overridesEquals". But it does not take into account the subclasses, that can implement "equals". So, we have two classes: A and B --> A The both classes are persistent. The class A does not override "equals". The class B overrides. Then when the instance of B is loaded lazily (and it referenced as A), the proxy ...

48. Proper equals() implementation for sets?    forum.hibernate.org

Sounds kinda simple, but it has proven to be a tough nut to crack... If we have a class pojo and a student pojo, the class has a set of students and the student has a set of classes (managed by separate class_student table), and both sets in the mapping files are defined as lazy. How do you construct the equals() ...

49. bug in org.hibernate.engine.EntityKey.equals() ??    forum.hibernate.org

I'm running into a similar problem. We have a Person class that is extended by both User and Patient classes and Person.personId = User.userId = Patient.patientId After Patient #550 is loaded into the session/transaction cache, any calls to get or load for User #550 will return the patient #550 because of the above mentioned code in EntityKey.equals(). Can someone speak to ...

50. proxy-safe equals tester    forum.hibernate.org

I was at a Java User Group last night where the presenter went over proxying. Specifically, he went over some rules that should be followed to make your entity classes better candidates for proxying, and optimizing them for proxying. A couple of rules that he pointed out were no final entity classes no final methods in the entities equals through getters, ...

51. Is there unsaved-value="" equivalent in JPA annota    forum.hibernate.org

Probably No. Identifier mappings The unsaved-value attribute is now optional, in most cases. Hibernate will use unsaved-value="0" as the default, where that is sensible. Note: In Hibernate3, it is no longer necessary to implement Interceptor.isUnsaved() when using natural keys (assigned identifiers or composite identifiers) and detached objects. In the absence of any "hints", Hibernate will query the database to determine if ...

52. Hibernate and equals    forum.hibernate.org

Hi First of all I suggest you change the implementation of you equals method to accomodate other cases like a null Object or an object of a different class. Otherwise you could run into some more weird errors. The equals/hashCode situation is pretty nicely described in Josh Bloch's Effective Java Programming and other related articles you can find across the internet. ...

53. findDirty equivalent & onDirtyCheck not called    forum.hibernate.org

Hibernate version: 3.2.5 ga Hi everyone, Is there a simmilar event listener method to org.hibernate.Interceptor.findDirty()? I need to catch all the instances that changed in persistence ctx before it gets flushed to DB. Need to catch pojo that was changed with something like: Code: pojo.setProperty("a"); dao.save(pojo); I tried to register DirtyCheckEventListener on dirty-check but that will be not called for some ...

54. equals/hash code problems    forum.hibernate.org

In my application all the objects stored in the database have an integer code. I've developed the following functions: Code: @Override public int hashCode() { //This method has been reimplemented because of Hibernate. See Hibernate tutorials for more info. ...

55. What is the equivalent of net.sf.hibernate in Hibernate 3 ?    forum.hibernate.org

As far as I know the classes in package net.sf.hibernate which are imported in Java refer to Hibernate 2. What are the equivalent imports for Hibernate 3? Do I have to rewrite old Hibernate 2 Java sources so that they work with Hibernate 3 or do I have just to change the "import" statements ? Peter

56. Java indexOf equivalent in Hibernate?    forum.hibernate.org

I need to search through my database for values that have a property that contains an input value. I've been looking through the HQL and Criterion API's and I can't really find anything that meets what I'm looking for. I basically want to achieve this result: for (User user : userList) { if (user.getName().indexOf(value) != -1) addUserToResultList(user); } Or this result, ...

57. equals automation?    forum.hibernate.org

Hi all, I just wondered whether there's a helper class or an other mechanism in hibernate which calculates hashCode() values and performs the equals()-method. If not, take my question as a feature request. It shouldn't be too difficult to build since hibernate has all needed information about the objects properties in its mapping files and already makes strong use of reflection. ...

58. Removal from many-many set fails -- problem with equals()    forum.hibernate.org

Author Message jkranes Post subject: Removal from many-many set fails -- problem with equals() Posted: Tue Sep 01, 2009 6:15 pm Newbie Joined: Tue Sep 01, 2009 5:33 pm Posts: 2 Hi, I'm just getting started with Hibernate -- apologies in advance. I have a many-many relationship of Users and Groups. The crux of the issue is this: The ...