-->
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.  [ 6 posts ] 
Author Message
 Post subject: [Hibernate 5.1.0.Final] @joinTable without attribute catalog
PostPosted: Wed Apr 27, 2016 11:14 am 
Newbie

Joined: Wed Feb 24, 2016 12:21 pm
Posts: 5
I migrate an application from hibernate 4 to hibernate 5.1.0.Final, and i have an issue with annotation @joinTable: if i don't defind the attribute catalog i have this error :

Code:
org.hibernate.exception.SQLGrammarException: Error accessing table metadata
   at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.convertSQLException(InformationExtractorJdbcDatabaseMetaDataImpl.java:99) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.locateTableInNamespace(InformationExtractorJdbcDatabaseMetaDataImpl.java:354) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getTable(InformationExtractorJdbcDatabaseMetaDataImpl.java:228) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.tool.schema.internal.exec.ImprovedDatabaseInformationImpl.getTableInformation(ImprovedDatabaseInformationImpl.java:109) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.tool.schema.internal.SchemaMigratorImpl.performMigration(SchemaMigratorImpl.java:252) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:137) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:110) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:176) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:64) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:458) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:465) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:881) ~[hibernate-entitymanager-5.1.0.Final.jar:5.1.0.Final]
   ... 194 common frames omitted
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name.
   at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:254) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:84) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:39) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.SQLServerConnection$1ConnectionCommand.doExecute(SQLServerConnection.java:1756) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectionCommand(SQLServerConnection.java:1761) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.setCatalog(SQLServerConnection.java:2063) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.switchCatalogs(SQLServerDatabaseMetaData.java:326) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getResultSetFromStoredProc(SQLServerDatabaseMetaData.java:277) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getResultSetWithProvidedColumnNames(SQLServerDatabaseMetaData.java:304) ~[sqljdbc-4.0.jar:na]
   at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getTables(SQLServerDatabaseMetaData.java:466) ~[sqljdbc-4.0.jar:na]
   at org.apache.commons.dbcp.DelegatingDatabaseMetaData.getTables(DelegatingDatabaseMetaData.java:604) ~[commons-dbcp-1.4.jar:1.4]
   at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.locateTableInNamespace(InformationExtractorJdbcDatabaseMetaDataImpl.java:339) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
   ... 204 common frames omitted


how to resolve this issue without using this attribute, it's a regression?


Top
 Profile  
 
 Post subject: Re: [Hibernate 5.1.0.Final] @joinTable without attribute catalog
PostPosted: Thu Apr 28, 2016 1:21 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You need to provide the query, the entity mappings, and more context to understand the actual issue.


Top
 Profile  
 
 Post subject: Re: [Hibernate 5.1.0.Final] @joinTable without attribute catalog
PostPosted: Thu Apr 28, 2016 4:34 am 
Newbie

Joined: Wed Feb 24, 2016 12:21 pm
Posts: 5
thanks for your reply, this is the informations required

the context :

Spring-boot 1.3.2.RELEASE
Jpa 2.1
Hibernate 5.1.0.Final
sqlserver 2005

jpa properties :
hibernate.hbm2ddl=validate
hibernate.default_catalog=PARAM_PM_DEV
hibernate.connection.default_schema=PARAMETRAGE_TARIFAIRE
jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc:sqlserver://127.0.0.1:1433;shutdown=false

the entity mappings :
Code:
@Entity
@Table(name = "ZONE_GEOGRAPHIQUE_ZGE", schema = "LOCALISATION")
public class PTAZoneGeographique {

    /** Identifiant technique de la zone géographique. */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ZGE_ID")
    protected Integer id;

    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
    @Fetch(FetchMode.SELECT)
    @BatchSize(size = 250)
@JoinTable(schema = "LOCALISATION", name = "ZG_COMMUNES_ZGC", joinColumns = @JoinColumn(name = "ZGC_ZONE_GEOGRAPHIQUE_ID", referencedColumnName = "ZGE_ID"), inverseJoinColumns = @JoinColumn(name = "ZGC_COMMUNE_ID", referencedColumnName = "COM_ID"))
    protected List<PTACommune> communes = new LinkedList<>();



Code:
@Entity
@Table(schema = "LOCALISATION", name = "COMMUNE_COM")
public class PTACommune {
 
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "COM_ID")
    protected Integer id;

    @Column(name = "COM_CODE_INSEE", nullable = false)
    private String codeINSEE;

    @Column(name = "COM_LIBELLE", nullable = false)
    private String libelle;


Top
 Profile  
 
 Post subject: Re: [Hibernate 5.1.0.Final] @joinTable without attribute catalog
PostPosted: Thu Apr 28, 2016 5:42 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
I see some possible issue here. First, you defined the following connection-level property:

Code:
hibernate.connection.default_schema=PARAMETRAGE_TARIFAIRE


But on the entity mapping, the schema is set to:

Code:
schema = "LOCALISATION"


I'll remove the "hibernate.connection.default_schema" property and replace it with:

Code:
hibernate.default_schema=LOCALISATION


Let me know if it works.


Top
 Profile  
 
 Post subject: Re: [Hibernate 5.1.0.Final] @joinTable without attribute catalog
PostPosted: Thu Apr 28, 2016 6:42 am 
Newbie

Joined: Wed Feb 24, 2016 12:21 pm
Posts: 5
I set the default_schema to PARAMETRAGE_TARIFAIRE because i have a several schemas and by default i want to use PARAMETRAGE_TARIFAIRE.

it does'nt works when i set the default_schema to LOCALISATION


Top
 Profile  
 
 Post subject: Re: [Hibernate 5.1.0.Final] @joinTable without attribute catalog
PostPosted: Thu Apr 28, 2016 6:56 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Then it might be an issue. Can you provide a replicating test case so we can open an issue? You can use these templates.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.