We're updating the issue view to help you get more done. 

Validation schema not work with sequence throws synonym

Description

I use entity bean without schema with sequence generator.

@Entity
@SequenceGenerator(name = "SEQ_B_ID", sequenceName = "SEQ_B_ID")
class B {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_B_ID")
int id;
}

I need two user, one for insert, and next for select (only select, is for web). In Oracle I have INS schema with table B and WEB schema with synonym B for table B from INS schema.

When I set "hbm2ddl.auto=validate" and run with WEB user catch org.hibernate.HibernateException: Missing sequence or table: SEQ_B_ID

Full Stack:

Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring-database.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Missing sequence or table: SEQ_B_ID:
org.hibernate.HibernateException: Missing sequence or table: SEQ_B_ID
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1100)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
and more ...

It is important that, without hbm2ddl.auto (no presence, default) everything works.

Environment

Oracle 10g

Status

Assignee

DiegoP

Reporter

LiborL

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

3.2.6

Priority

Major