-->
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.  [ 2 posts ] 
Author Message
 Post subject: SchemaManagementException: Schema-validation: missing table
PostPosted: Sat May 27, 2017 8:52 am 
Newbie

Joined: Sat May 27, 2017 8:46 am
Posts: 1
Error - org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table

package org.rahul;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
public class UserDetails
{
@Id
int userId;
String userName;
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}

}


package org.rahul;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateTest{


public static void main(String arg[])
{
UserDetails user = new UserDetails();

user.setUserId(1);
user.setUserName("Rahul");

Configuration cfg=new Configuration();
cfg.configure("hibernate.cfg.xml");//populates the data of the configuration file

//creating seession factory object
System.out.println("---");
SessionFactory factory=cfg.buildSessionFactory();
System.out.println("-hh--");

Session session = factory.openSession();

session.beginTransaction();
session.save(user);
session.getTransaction().commit();
System.out.println("Done..");
}
}


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


<hibernate-configuration>
<session-factory>

<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;databaseName=FromHibernate;</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password">rahul</property>
<property name="hibernate.hbm2ddl.auto">validate</property>
<property name="connection.pool_size">1</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping class="org.rahul.UserDetails"/>
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject: Re: Need Help To Solve This Problem
PostPosted: Sat May 27, 2017 9:21 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Most likely, you don't have the UserDetails table in the database, and the validate strategy has detected that.

<property name="hibernate.hbm2ddl.auto">validate</property>

Create the table and see it working.


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