Hibernate ORM
  1. Hibernate ORM
  2. HHH-8183

Also support synonyms for schema validation

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.3.2
    • Fix Version/s: 4.2.1, 4.3.0.Beta2
    • Component/s: core
    • Labels:
    • Environment:
      JBoss EAP 5.1.1
    • Last commented by a user?:
      true

      Description

      At the moment, if you activate "hibernate.hbm2ddl.auto=validate", then hbm2ddl will fail since it won't look for synonyms.

      The related code seems to be in DatabaseMetadata :

        private static final String[] TYPES = {"TABLE", "VIEW"};
      

      might be replaced with something like

        private static final String[] TYPES = {"TABLE", "VIEW", "SYNONYM"};
      

      I'm gonna have a look at the code to see if I can provide a patch.
      I also found some seemingly related JIRAs, but I filed this one since I didn't find something specific to synonyms (I'll also have to get my hands dirty with Gradle, fingers crossed ).

      Thanks

        Issue Links

          Activity

          Hide
          Brett Meyer added a comment -
          Show
          Brett Meyer added a comment - Pull request: https://github.com/hibernate/hibernate-orm/pull/508
          Hide
          Brett Meyer added a comment -

          Baptiste MATHUS, as Steve Ebersole mentioned on your pull request, including synonyms can cause Oracle to return duplicates. Max Rydahl Andersen, anything to add there?

          Baptiste MATHUS, would it be sufficient if we worked in a setting that would allow synonyms, but disabled it by default?

          Show
          Brett Meyer added a comment - Baptiste MATHUS , as Steve Ebersole mentioned on your pull request, including synonyms can cause Oracle to return duplicates. Max Rydahl Andersen , anything to add there? Baptiste MATHUS , would it be sufficient if we worked in a setting that would allow synonyms, but disabled it by default?
          Hide
          Baptiste MATHUS added a comment -

          As I just commented on the PR, I actually had the same idea.
          I think you're right. It's far less risky and will anyway get people satisfied (including not just me from the other JIRAs I can see ).

          Show
          Baptiste MATHUS added a comment - As I just commented on the PR, I actually had the same idea. I think you're right. It's far less risky and will anyway get people satisfied (including not just me from the other JIRAs I can see ).
          Hide
          Rafael Horácio added a comment -

          I'm using hibernate-core-4.2.1.Final.jar in project, I add a property in persistence.xml, like that:
          [property name="hibernate.synonyms" value="true"]
          When I'm starting the server, I get an error 'schema validation', saying 'table not found', but, it is a Synonym.

          only these configuration in my project, it should works?

          Show
          Rafael Horácio added a comment - I'm using hibernate-core-4.2.1.Final.jar in project, I add a property in persistence.xml, like that: [property name="hibernate.synonyms" value="true"] When I'm starting the server, I get an error 'schema validation', saying 'table not found', but, it is a Synonym. only these configuration in my project, it should works?
          Hide
          Brett Meyer added a comment -

          Rafael Horácio, HHH-8226 follows this up with an additional fix. Give that a try (4.2.2-SNAPSHOT). Alternatively, add "hibernate.connection.includeSynonyms=true"

          Show
          Brett Meyer added a comment - Rafael Horácio , HHH-8226 follows this up with an additional fix. Give that a try (4.2.2-SNAPSHOT). Alternatively, add "hibernate.connection.includeSynonyms=true"
          Hide
          Rafael Horácio added a comment -

          Hi,
          I try it: 4.2.2-SNAPSHOT version, but it does not work.

          1. Log console JBoss:
          14:11:51,829 INFO [Version] HHH000412: Hibernate Core {4.2.2-SNAPSHOT}

          2. Exception: org.hibernate.HibernateException
          Missing column: ID_TESTE_D in ATHOS_DES.TESTE_D

          Show
          Rafael Horácio added a comment - Hi, I try it: 4.2.2-SNAPSHOT version, but it does not work. 1. Log console JBoss: 14:11:51,829 INFO [Version] HHH000412: Hibernate Core {4.2.2-SNAPSHOT} 2. Exception : org.hibernate.HibernateException Missing column: ID_TESTE_D in ATHOS_DES.TESTE_D
          Hide
          Brett Meyer added a comment -

          Rafael Horácio, are you using a datasource? If so, the "includeSynonyms" property needs to be added there.

          Show
          Brett Meyer added a comment - Rafael Horácio , are you using a datasource? If so, the "includeSynonyms" property needs to be added there.
          Hide
          Rafael Horácio added a comment -

          Thank you very much Brett Meyer
          it works correctly added that property in datasource file standalone.xml

          <connection-property name="includeSynonyms">
             true
          </connection-property>
          
          Show
          Rafael Horácio added a comment - Thank you very much Brett Meyer it works correctly added that property in datasource file standalone.xml <connection-property name= "includeSynonyms" > true </connection-property>

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development