-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Variant accessors & case sensitive names: 4.3/5.0.11/5.2.7
PostPosted: Fri Feb 03, 2017 2:45 am 
Newbie

Joined: Thu Feb 02, 2017 11:53 pm
Posts: 2
Hi all,

We are upgrading an application from JBoss EAP 6.4 to the newest EAP 7.0, and along with that comes a move from Hibernate 4.3 to 5. I've come across a couple of behaviours that forced me to make code changes for the newest version, and was wondering whether there are configuration options I've missed, or these are features or even bugs in the latest releases?

Here's our platform:
  • JBoss 7.0.3 (soon 7.0.4)
    • Hibernate Core 5.0.11.Final-redhat-1 -> upgraded to Hibernate Core 5.2.7.Final
    • Hibernate Validator 5.2.4.Final-redhat-1 -> upgraded to Hibernate Validator 5.4.0.Final
    • Hibernate Commons Annotations {5.0.1.Final-redhat-2}
  • Microsoft SQL Server 2012

I had to upgrade Hibernate Core for HHH-10978 (even though that bug was reportedly fixed in 5.0.11, I still encountered it; happily deploying 5.2.7 fixed it). I've also upgraded Hibernate Validator to see if it made a difference to my issues below, but as there was no change we probably won't deploy this when the setup is migrated to other environments.


Number 1: We had a couple of entity classes like this:
Code:
package xxx;
<imports omitted...>

/**
* An audit of the processing of a data load file, both automatically and manually initiated steps, starting from the
* discovery of the file and ending with the archiving of the file.
*/
@Entity
public class DataLoadFileEvent
{
    <unrelated members omitted...>
    private Boolean reported;

    public DataLoadFileEvent()
    {

    }

    public void setReported(Boolean reported)
    {
        this.reported = reported;
    }

    public Boolean getReported()
    {
        return this.reported;
    }

    @Transient
    public boolean isReported()
    {
        boolean ret = false;
        if (reported != null)
        {
            ret = reported;
        }
        return ret;
    }
}
Note the getReported() accessor returning the member (big-B) Boolean, and the convenience method isReported() that returns the unwrapped (small-b) boolean value. This code worked in Hibernate 4.3, but under 5.0.11 and 5.2.7 throws the following exception:
Quote:
org.hibernate.MappingException: In trying to locate getter for property [reported], Class [xxx.DataLoadFileEvent] defined both a `get` [public java.lang.Boolean xxx.DataLoadFileEvent.getReported()] and `is` [public boolean xxx.DataLoadFileEvent.isReported()] variant
However, isReported() is marked with the @Transient annotation, so it should be ignored, should it not?

(I can concede it's maybe not great class design, and it isn't a breaking code change for us as there were only three instances that either weren't referenced or that I could refactor - but I'm still puzzled as to why it isn't allowed with @Transient in version 5.)


Number 2: We had many entity classes with an @Entity or @Table annotation specifying a name or schema that did not match the capitalisation of the table in the database, for example:
Code:
@Entity(name="appDefect")
public class ApplicationDefect

where the table is named AppDefect. This all worked in 4.3 and 5.0.11, but not in 5.2.7, which complained about table not found. When the capitalization was corrected, it worked, but as this changed spontaneously between minor versions I'm wondering whether it was intentional and if there is a configuration setting to make it case-insensitive again?

(Again, not a breaking code change but I had to edit around 60 entities to get it to run again.)


Thanks in advance for any advice or explanations.


Top
 Profile  
 
 Post subject: Re: Variant accessors & case sensitive names: 4.3/5.0.11/5.2.7
PostPosted: Mon Feb 06, 2017 4:24 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
If the HHH-10978 bug is not fixed in 5.0, you should add a comment to it so that Gail knows about it.

1. Related to the isReported and getReported methods, I think we should skip the transient methods. You should open a new issue and add a link in this forum thread.

2. Due to performance reasons, we try to fetch the whole Metadata at once and do the checkings based on what the DB has returned. If the DB is case insensitive, you should use the same case as the database. I think this is a better default than what it was used previously.


Top
 Profile  
 
 Post subject: Re: Variant accessors & case sensitive names: 4.3/5.0.11/5.2.7
PostPosted: Wed May 03, 2017 12:13 am 
Newbie

Joined: Thu Feb 02, 2017 11:53 pm
Posts: 2
I was waylaid for some time, but here 'tis:
https://hibernate.atlassian.net/browse/HHH-11716

Edit: related articles
https://hibernate.atlassian.net/browse/HHH-10978
https://hibernate.atlassian.net/browse/HHH-11374


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.