• Post Reply Bookmark Topic Watch Topic
  • New Topic

I am facing a problem and not able to get this problem, please can any one help me  RSS feed

 
Jay Mathur
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/* Pojo file*/

@Entity
@Table(name="newrc")
@SecondaryTable(name="secondrc")
public class Login {

private String userId;
private String userName;

private String address;
private String contNo;

@Id
@GeneratedValue
@Column(name="studentId")
public String getUserId() {
return userId;
}

public void setUserId(String id) {
this.userId = userId;
}

public String getUserName() {
return userName;
}


public void setUserName(String userName) {
this.userName = userName;
}

@Column(table="secondrc")
public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

@Column(table="secondrc")
public String getContNo() {
return contNo;
}


public void setContNo(String contNo) {
this.contNo = contNo;
}


/*---------------*/
public static void main(String[] args) {
// TODO code application logic here

AnnotationConfiguration ac=new AnnotationConfiguration();
ac.addAnnotatedClass(Login.class);
ac.configure("hibernate.cfg.xml");

new SchemaExport(ac).create(true, true);

SessionFactory factory=ac.buildSessionFactory();
Session ses=factory.openSession();

ses.beginTransaction();

Login login=new Login();

// log.setId("100");
login.setUserName("Rohit");
login.setAddress("Delhi");
login.setContNo("3672698798");

ses.save(login);

ses.getTransaction().commit();

}

/*------This is the Error-------*/
alter table secondrc drop foreign key FK383C05A565EA9146
drop table if exists newrc
drop table if exists secondrc
create table newrc (studentId varchar(255) not null auto_increment, userName varchar(255), primary key (studentId))
Jul 15, 2014 12:29:06 AM org.hibernate.tool.hbm2ddl.SchemaExport create
SEVERE: Unsuccessful: create table newrc (studentId varchar(255) not null auto_increment, userName varchar(255), primary key (studentId))
Jul 15, 2014 12:29:06 AM org.hibernate.tool.hbm2ddl.SchemaExport create
SEVERE: Incorrect column specifier for column 'studentId'
create table secondrc (address varchar(255), contNo varchar(255), studentId varchar(255) not null, primary key (studentId))
alter table secondrc add index FK383C05A565EA9146 (studentId), add constraint FK383C05A565EA9146 foreign key (studentId) references newrc (studentId)
Jul 15, 2014 12:29:06 AM org.hibernate.tool.hbm2ddl.SchemaExport create
SEVERE: Unsuccessful: alter table secondrc add index FK383C05A565EA9146 (studentId), add constraint FK383C05A565EA9146 foreign key (studentId) references newrc (studentId)
Jul 15, 2014 12:29:06 AM org.hibernate.tool.hbm2ddl.SchemaExport create
SEVERE: Can't create table '.\stp\#sql-780_a7.frm' (errno: 150)
Jul 15, 2014 12:29:06 AM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: schema export complete
Jul 15, 2014 12:29:06 AM org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:mysql://localhost:3306/stp
Jul 15, 2014 12:29:06 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Jul 15, 2014 12:29:06 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Jul 15, 2014 12:29:06 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Jul 15, 2014 12:29:06 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/stp
Jul 15, 2014 12:29:06 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=****}
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.10a-beta-nt
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.13 ( Revision: ${bzr.revision-id} )
Jul 15, 2014 12:29:06 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Jul 15, 2014 12:29:06 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Jul 15, 2014 12:29:06 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
Jul 15, 2014 12:29:06 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Jul 15, 2014 12:29:06 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Jul 15, 2014 12:29:07 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Jul 15, 2014 12:29:07 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
Jul 15, 2014 12:29:07 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Jul 15, 2014 12:29:07 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Jul 15, 2014 12:29:07 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
Jul 15, 2014 12:29:07 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Jul 15, 2014 12:29:07 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Jul 15, 2014 12:29:07 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Jul 15, 2014 12:29:07 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Jul 15, 2014 12:29:07 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Jul 15, 2014 12:29:07 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
Jul 15, 2014 12:29:07 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Jul 15, 2014 12:29:07 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Jul 15, 2014 12:29:07 AM org.hibernate.tool.hbm2ddl.SchemaValidator validate
INFO: Running schema validator
Jul 15, 2014 12:29:07 AM org.hibernate.tool.hbm2ddl.SchemaValidator validate
INFO: fetching database metadata
Jul 15, 2014 12:29:07 AM org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: table not found: newrc
Exception in thread "main" org.hibernate.HibernateException: Missing table: newrc
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1080)
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:1294)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
at com.hp.LoginMain.main(LoginMain.java:30)
Java Result: 1
BUILD SUCCESSFUL (total time: 4 seconds)
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect the problem is given in the output here:

SEVERE: Unsuccessful: create table newrc (studentId varchar(255) not null auto_increment, userName varchar(255), primary key (studentId))
Jul 15, 2014 12:29:06 AM org.hibernate.tool.hbm2ddl.SchemaExport create
SEVERE: Incorrect column specifier for column 'studentId'
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!