-->
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.  [ 1 post ] 
Author Message
 Post subject: hibernate.hbm2ddl.auto=validate with 2 schemas
PostPosted: Mon Apr 22, 2013 2:44 pm 
Newbie

Joined: Mon Apr 22, 2013 1:44 pm
Posts: 1
Hi

I'm using the hibernate.hbm2ddl.auto=validate in my persistence.xml with two tables that have the same name from two distinct schema using oracle synonyms to choose the schema but the validator ignor the synonyms and always find same table to validate. Because he use the connection.getMetaData() to get the tables informations and return the firth table name matches. The problem is validation failed because the tables are different but the code run because the queries use the synonyms.

It is possible to see in the method getTableMetadata(String name, String schema, String catalog, boolean isQuoted) from org.hibernate.tool.hbm2ddl.DatabaseMetadata.java

the parameters are Table_TEST, null, null true

the tables are:
create table schema1.Table_TEST {
teste1 number null,
}


create table schema2.Table_TEST {
teste2 number null,
}

synonyms is schema2 but always the metod return schema1.Table_TEST

public TableMetadata getTableMetadata(String name, String schema, String catalog, boolean isQuoted) throws HibernateException {
75
76 Object identifier = identifier(catalog, schema, name);
77 TableMetadata table = (TableMetadata) tables.get(identifier);
78 if (table!=null) {
79 return table;
80 }
81 else {
82
83 try {
84 ResultSet rs = null;
85 try {
86 if ( (isQuoted && meta.storesMixedCaseQuotedIdentifiers())) {
87 rs = meta.getTables(catalog, schema, name, TYPES);
88 } else if ( (isQuoted && meta.storesUpperCaseQuotedIdentifiers())
89 || (!isQuoted && meta.storesUpperCaseIdentifiers() )) {
90 rs = meta.getTables(
91 StringHelper.toUpperCase(catalog),
92 StringHelper.toUpperCase(schema),
93 StringHelper.toUpperCase(name),
94 TYPES
95 );
96 }
97 else if ( (isQuoted && meta.storesLowerCaseQuotedIdentifiers())
98 || (!isQuoted && meta.storesLowerCaseIdentifiers() )) {
99 rs = meta.getTables(
100 StringHelper.toLowerCase(catalog),
101 StringHelper.toLowerCase(schema),
102 StringHelper.toLowerCase(name),
103 TYPES
104 );
105 }
106 else {
107 rs = meta.getTables(catalog, schema, name, TYPES);
108 }
109
110 while ( rs.next() ) {
111 String tableName = rs.getString("TABLE_NAME");
112 if ( name.equalsIgnoreCase(tableName) ) {
113 table = new TableMetadata(rs, meta, extras);
114 tables.put(identifier, table);
115 return table; //First match without consider synonyms
116 }
117 }
118
119 log.info("table not found: " + name);
120 return null;
121
122 }
123 finally {
124 if (rs!=null) rs.close();
125 }
126 }
127 catch (SQLException sqle) {
128 throw JDBCExceptionHelper.convert(
129 sqlExceptionConverter,
130 sqle,
131 "could not get table metadata: " + name
132 );
133 }
134 }
135
136 }



It is a hibernate error?


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

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.