1. equals and hashcode in Hibernate stackoverflow.comHow should model class's equals and hashcode be implemented in Hibernate? What are the common pitfalls? Is the default implementation good enough for most cases? Is there any sense to use ... |
2. To equals and hashcode or not on entity classes, that is the question stackoverflow.comI have been trying to reason about the best way to handle whether it is generally good practice to implement hashcode and equals on entities (I mean entity in the general ... |
3. Entities equals(), hashCode() and toString(). How to correctly implement them? stackoverflow.comI'm implementing |
4. Should @Transient property be used in equals/hashCode/toString? stackoverflow.comthis is a quick question:
I have JPA entities where some properties are annotated with |
5. How to implement equals() and hashcode() methods in BaseEntity of JPA? stackoverflow.comI have BaseEntity class which is a superclass of all JPA entities in my application.
|
6. Using natural keys as part of equals and hashCode stackoverflow.comI know that this topic has been discussed umpteen number of times, but still need some clarifications on the issue we are facing. Hibernate best practices talk about using ... |
7. apache commons equals/hashcode builder stackoverflow.comI'm curious to know, what people here think about using org.apache.commons.lang.builder EqualsBuilder/HashCodeBuilder for implementing the equals/hashcode? Would it be a better practice than writing your own? Does it play well with Hibernate? ... |
8. Changing hashCode of object stored in hash-based collection stackoverflow.comI have a hash-based collection of objects, such as |
9. Implement hashCode and equals on base entity class (possibly using reflection)? stackoverflow.comI am wondering whether it is a good practice to have |
10. equals() and hashCode() when storing in a Set, in Hibernate stackoverflow.comIn Hibernate documentation in chapter 4.3. "Implementing equals() and hashCode()" they wrote this sentence "Furthermore, if an instance is unsaved and currently in a Set, saving it will assign ... |
11. Implementation of equals() and hashCode() when no natural key is available? stackoverflow.comThis question is basically a follow-up to questions: Should I write equals() methods in JPA entities? and What is the best practice when implementing equals() for entities with generated ids Some ... |
12. How hibernate uses equals() and hashCode()? stackoverflow.comIf you load an entity from db and modify it somehow, will hibernate use equals/hashCode to compare current state of entity with it's snapshot to determine if sql update needs to ... |
13. JPA, equals and hashCode java.netOption 1: Leave as Object.equals and Object.hashCode + Less code to write + Can add multiple new child entities into a collection - Could have issues adding persisted entities into a collection if you manage to get them from different sessions - Have to search the entire collection with an iterator to check for contents |
14. equals and hashCode not invoked forum.hibernate.org |
15. Problem with hashCode() implementation forum.hibernate.orgAuthor Message Stef_Kuypers Post subject: Problem with hashCode() implementation Posted: Tue Oct 20, 2009 6:14 am Newbie Joined: Fri Aug 14, 2009 8:06 am Posts: 19 The docs say that to make sure objects from different sessions behave correctly in respect to hashCode() and equals() methods one should override these methods and use hashCode() and equals() on the business ... |
16. _not_ a yet another broken hashCode problem! forum.hibernate.orgNewbie Joined: Wed Nov 04, 2009 9:30 am Posts: 1 Hello everyone! I'm quite new to Hibernate (has been fiddling with it for a week now). About 3 days ago I came across a very annoying bug that I was unable to correct ever since. The problem lies in a many-to-many relationship between objects called RawFilters, DataOrigins and RawData. Specifically a ... |
17. Why doesn't SimpleExpression implement hashcode and equals? forum.hibernate.orgNewbie Joined: Mon Mar 22, 2010 8:45 pm Posts: 1 I have a class called WhereClause that has the following method... Code: public void appendWhereClause( Criteria query ) { if ( !CollectionUtils.isEmpty( this.getProperties() ) ) { ... |
18. Hibernate equals() and hashCode() not called forum.hibernate.orgdear all, i am using Hibernate 3.5.4 final with Annotations Configuration although I implemented the methods equals() and hashCode() in the persistence classes they are not called by hibernate. I inserted some print-outs, but nothing is written on console. Also when putting breakpoints, they are never reached. The classes are using the annotations: ------------------------------------------------------ @Entity @Inheritance(strategy = InheritanceType.JOINED) ------------------------------------------------------ and several ... |
19. Best practice? Lazy collection in equals()/hashCode() forum.hibernate.orgHi, We have a few classes from our legacy app that uses lazy-loaded collections in their equals/hashCode methods. I have read that this is bad practice as the state of this classes could mutate. However, it was working fine in Hibernate 3.2.6 without issues and now with the newer 3.5/3.6 we get an org.hibernate.AssertionFailure: collection [...] was not processed by flush() ... |
20. hashcode & equals automation? forum.hibernate.orgHi 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. ... |
21. proxy/hashCode/equals forum.hibernate.orgGavin (I hope you will read this), I found another source of ConcurrentModificationException in my code. It is nothing new - just another collection of proxied classes with equals() overriden. Unfortunately I have spent alot of time before realizing this exception is caused by my simplest possible equals() implementation ( which only compares Ids ). Since Hibernate does not know how ... |
22. HELP! problems with hashCode() forum.hibernate.orgI'm using Hibernate 2.1.1. I want to insert a Mp with two MpRequisitosQual in it's "Set". But when I do this, it only inserts the first MpRequisitosQual! By the generated code (hbm2java), I see that the equality between two objects is made via there "id". And when I add the second MpRequisitosQual to the "Set", he's discarded because there's already an ... |
23. HELP! problems with hashCode() forum.hibernate.orgI'm using Hibernate 2.1.1. I want to insert a Mp with two MpRequisitosQual in it's "Set". But when I do this, it only inserts the first MpRequisitosQual! By the generated code (hbm2java), I see that the equality between two objects is made via there "id". And when I add the second MpRequisitosQual to the "Set", he's discarded because there's already an ... |
24. equals() / hashCode(): Is there *any* non-broken approach? forum.hibernate.orgWe're grappling with how to implement equals()/hashCode() on our persistent objects. The Hibernate page on the subject recommends using a "semi-unique key" for equals, instead of ID. That doesn't work -- very few of our objects actually have such a key, and IMO it's terrible advice anyway: "Use some other ID that is not the ID as your ID for the ... |
25. Proxies with hashCode() and equals() forum.hibernate.orgNot sure if I can make it any clearer than all the resources you say you have already seen, but here it goes (maybe I can at least make it more condensed): The issue has to do not so much with the entity itself defining equals/hashCode. Its more a problem of those entities which do define an equals/hashCode being included in ... |
26. hashCode, equals, Proxies and 2nd Level Cache - solution? forum.hibernate.orgNewbie Joined: Wed May 19, 2004 1:25 pm Posts: 11 Okay, I'm very new to hibernate. I've got the problem where I'm composing a Set before I save an object graph. After a bit of thinking, and a bit of reading, I dont think anyone else has the solution. fyi Its obvious that the hashcode will change if its based on ... |
27. Can't hibernate enhance equals/hashcode() too? forum.hibernate.orgI have read the article from wiki and , the this way of implementing equals and hashcode() is really weird. Can't hibernate enhance equals/hashcode() too? say , when add 2 new instance in session, hibernate compare them with instance equality, when 2 detached compared,or 1 detached instance with 1 instance loaded in session, hibernate can compare them with orig ID( hibernate ... |
28. equals() and hashCode() philosophy. forum.hibernate.orgIn my last go-around with our domain model (using entity beans) our equals() implementation only took into account the surrogate primary key value. This was problematic for clients while creating new objects (which would only compare references), and in moving the code to hibernate I took note of the HiA book's warning that an implementation of hashCode() which involved the surrogate ... |
29. HashCode - Equals forum.hibernate.orgHi! Even it is an old posting, I think it is still up to date. I have read the very good description about hashCode() and equals() in 'Java Persistence with Hibernate' and understand why to use the business key. However I see two problems with it: As described above the usage of the business key can make from an lazy association ... |
30. About equals and hashcode in hibermate java files forum.hibernate.orgIn "Hibernate in Action" I read about the best practice to implement hashcode and equals for the persistent objects. It is not a good practice to use the "surrogate key" (database identifier property) because Hibernate doesnt assign identifier values until an entity is saved. Also it is not a good practice to include all persistent properties of the persistent class because ... |
31. hashCode called before properties are initialized forum.hibernate.orgHibernate version: 3.0.2 Hi, When I fetch an object from the database using Code: |
32. hashCode/equals questions - again forum.hibernate.orgHibernate version: 3.0.3 Can anyone shed some light on how to come up with the correct way to implement hashCode/equals methods for persistent objects stored as children in collection of parent objects? I have a model with some classes containing collections (sets and lists) of other, polymorphic, objects. Some of these objects have a 'business key' which depends on relationship (eg. ... |
33. equals() and hashCode() forum.hibernate.org |
34. Collections in hashCode and equals or not? forum.hibernate.org |
35. hashCode() in Hibernate 3.0.5, JBoss Cache, Multiple JVMs forum.hibernate.org |
36. Set and HashCode forum.hibernate.orgHi, I have the classes: UnidadMedida and ConversionUnidadMedida public class UnidadMedida { private Long id = null; private int version; private String nombre; private Set convertibleA; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public int getVersion() { return version; } public void setVersion(int version) { this.version = version; } public String getNombre() ... |
37. Feedback on an equals/hashCode approach forum.hibernate.orgNewbie Joined: Thu Oct 06, 2005 7:23 pm Posts: 7 I'd like to present and gain feedback on an alternate approach that we've come up with to the whole equals/hashCode problem. We haven't done extensive testing, and I'd like to hear about gotchas from those in the know prior to making a significant investment. After reading what's available (forums, Hib In ... |
38. Hashcode Computations forum.hibernate.orgI have some questions concerning the instructions on pp. 124-125 of Hibernate in Action where it talks about business key equality. 1. What is the recommended way to compute hashcodes when there is more than one property in the business key? Is it recommended to use an implementation like that on page 124? If so, how were the numbers "14" and ... |
39. hashCode question forum.hibernate.orgHello to everybody, I have the problem concerning hashCode/equals. I have 2 entities DbRssSpider and DbRssProperty an the following relation: Spider: Code: @OneToMany(mappedBy = "spider", cascade = { CascadeType.ALL}, targetEntity = DbRssProperty.class) @OrderBy("id") public Set |
40. Deep or Shallow: equals() and hashcode()? forum.hibernate.orgHibernate wants me to implement equals() and hashcode() for my persistent classes. Fine. However, this seems to be at odds with lazy loading and collections. For example: Category: String mNameString = "unnamed"; Set |
41. Do I have to implement equals() and hashcode()? forum.hibernate.org |
42. is there a better way to impl equals() and hashcode() ? forum.hibernate.orgas in the pojo, I can't find the unique properties in some case, that is, they might all be the same except the database identifier. I know it's a bad way of using database identifier to impl equals() and hashcode(), is there a better way when I can't determine the "bussiness key"? |
43. How to write hashCode and compareTo methods forum.hibernate.orgI need to mix saved and unsaved objects in Set. I have the following equals method: Code: public boolean equals(Object obj) { if (!(obj instanceof MyClass)) return false; else { ... |
44. Sets and contains - equals and hashcode forum.hibernate.orgHi I have a persistent object "Model", which contains a set of persistent objects "Feature". "Feature" has a single parameter, "name". In "Feature" I have overridden equals and hashcode to check the "name" value instead. e.g. Code: public int hashCode() { return this.getName().toUpperCase().hashCode(); } public boolean equals( Object _obj ) { if ( _obj instanceof Feature ) ... |
45. hashcode() and equals() forum.hibernate.orgHi, I have one many-to-many association table DepartmentToUser with columns: DepartmentID UserID PrimaryCode Now I want to create the domain object for it and override the hashcode() and equals() method. What properties should I use for that? I think I can not use DepartmentID and UserID because they are set by Hibernate when the objects are saved. PrimaryCode alone is not ... |
46. Equals and HashCode forum.hibernate.orgHey, I know that this is the most popular discussion, so sorry for raise it again. In my application the objects are equals if they are equals in all the fields (except ID). So few questions: 1. Do i need to check equals on all the fields include references, collections and etc. I looks on equals example and didnt saw that ... |
47. Hashcode and Equals on PK forum.hibernate.orgBeginner Joined: Sat Oct 20, 2007 8:28 am Posts: 28 hi here is my entity : Code: @Entity @AccessType("property") @Table(name = "stats") @IdClass(StatsPK.class) public class Stats implements Serializable,Comparable |
48. Do not initialize proxy when calling my overriden hashCode forum.hibernate.orgI've implemented a custom hashCode (and equals) method based on the id of my persistent object. This hashCode method works, even if it's a proxy. Code: @Override public int hashCode() { // getClass() is not hashbaar ... |
49. Many-To-Many update with mutable hashCode forum.hibernate.org@javax.persistence.Column(name = "SYSTEM_ID", insertable = true, updatable = true) public java.lang.String getSystemId() ... public int hashCode() { int hashCode = 0; hashCode = ... |
50. Problem with equals / hashcode forum.hibernate.orgNewbie Joined: Mon Jun 05, 2006 12:41 pm Posts: 19 Hibernate version: 3.2final Mapping documents: Code: |
51. hashcode and equals not used forum.hibernate.orgHibernate version: 3.3 Mapping documents: @Entity(name="T_APPLICATION") public class Application { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="APPLICATION_ID") private long id; @Column(name="APPLICATION_NAME", nullable=false) private String name; @Column(name="APPLICATION_CODE", nullable=false, unique=true) private String code; @OneToMany(mappedBy="relatedApplication", cascade=CascadeType.ALL) private List |
52. Removing Object from PersistentSet: NOT a hashCode problem! forum.hibernate.orgHello, I have a problem with removing an object from a 1:n relation from a PersistentSet. Removing the object works fine when done through the running application. However, the object is not removed when exactly the same code is executed initiated through a JUnit test case with exactly the same data. I'm sure it is not the usual problem of the ... |