Error accessing tables metadata

Hi expert,

I am now facing yet another problem.

There is a stackoverflow solution
https://stackoverflow.com/questions/7759170/mysql-table-doesnt-exist-but-it-does-or-it-should

where I had tried before but the solution is not a permanent cure so I would like to know how to make the error go away permanently.

And another one in your new site : https://discourse.hibernate.org/t/missing-table-while-table-exists/224 doesn’t help in my case cos I am not using JBOSS

Here’s the error message
table%20not%20exist%20-%20error%20accessing%20tables%20metadata

Please help me how to resolve it. Tks.

Also, I would like to check if the hibernate.cfg.xml file my location is it correct cos I read it has to be in the src source path? Tks.

Posting screenshots is of little use. You should add the entire stacktrace so that the root Exception can be seen. That’s where you need to look.

Hi vlad,

Here’s the full stack-trace for this part of error:
(keep my fingers crossed that it can go thru)

Mar 25, 2018 11:58:32 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 22262 ms
INFO  [http-nio-8080-exec-7]: Subject added
2018-03-25 12:05:32,124 http-nio-8080-exec-7 DEBUG AsyncLogger.ThreadNameStrategy=UNCACHED (user specified null, default is UNCACHED)
INFO  [http-nio-8080-exec-7]: Subject added
INFO  [http-nio-8080-exec-7]: Subject added
INFO  [http-nio-8080-exec-7]: Subject added
INFO  [http-nio-8080-exec-7]: Subject added
INFO  [http-nio-8080-exec-7]: Subject added
INFO  [http-nio-8080-exec-7]: HHH000412: Hibernate Core {5.2.10.Final}
INFO  [http-nio-8080-exec-7]: HHH000206: hibernate.properties not found
INFO  [http-nio-8080-exec-7]: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
WARN  [http-nio-8080-exec-7]: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
INFO  [http-nio-8080-exec-7]: HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/hi5s?useSSL=false]
INFO  [http-nio-8080-exec-7]: HHH10001001: Connection properties: {user=root, password=****}
INFO  [http-nio-8080-exec-7]: HHH10001003: Autocommit mode: false
INFO  [http-nio-8080-exec-7]: HHH000115: Hibernate connection pool size: 20 (min=1)
INFO  [http-nio-8080-exec-7]: HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
INFO  [http-nio-8080-exec-7]: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@1abe89f] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
WARN  [http-nio-8080-exec-7]: SQL Error: 1146, SQLState: 42S02
ERROR [http-nio-8080-exec-7]: Table 'hi5s.subject_tutor' doesn't exist
INFO  [http-nio-8080-exec-7]: HHH10001008: Cleaning up connection pool [jdbc:mysql://localhost:3306/hi5s?useSSL=false]
Problem creating session factory
INFO  [http-nio-8080-exec-7]: SessionFactory creation failed
org.hibernate.exception.SQLGrammarException: Error accessing tables metadata
	at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63)
	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
	at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.convertSQLException(InformationExtractorJdbcDatabaseMetaDataImpl.java:98)
	at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.populateTablesWithColumns(InformationExtractorJdbcDatabaseMetaDataImpl.java:383)
	at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getTables(InformationExtractorJdbcDatabaseMetaDataImpl.java:337)
	at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.getTablesInformation(DatabaseInformationImpl.java:120)
	at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:65)
	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:203)
	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:110)
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183)
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452)
	at util.HibernateUtil.getSessionFactory(HibernateUtil.java:38)
	at Business.RegisterService.register(RegisterService.java:24)
	at controller.tutorController.doPost(tutorController.java:90)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:417)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'hi5s.subject_tutor' doesn't exist
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
	at com.mysql.jdbc.Util.getInstance(Util.java:408)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2480)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2438)
	at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1381)
	at com.mysql.jdbc.DatabaseMetaData$2.forEach(DatabaseMetaData.java:2441)
	at com.mysql.jdbc.DatabaseMetaData$2.forEach(DatabaseMetaData.java:2339)
	at com.mysql.jdbc.IterateBlock.doForAll(IterateBlock.java:50)
	at com.mysql.jdbc.DatabaseMetaData.getColumns(DatabaseMetaData.java:2337)
	at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.populateTablesWithColumns(InformationExtractorJdbcDatabaseMetaDataImpl.java:350)
	... 39 more

The error is pretty straightforward:

Based on your JDBC URL:

jdbc:mysql://localhost:3306/hi5s

you are already connected to the hi5s catalog.

And, since MySQL does not support schemas, the problem is that you have defined your entities like this:

hi5s.subject_tutor

So, change your entities to point to the table without a schema:

@Entity
@Table(name = "subject_tutor")
public class SubjectTutor {
    ....
}

Hi vlad,

But, I do not have a model by SubjectTutor.
Are you suggesting I create one ?
Under the model layer, I only have Tutor, Subject and User
From the documentation that I read, there is none that mention that I should create a class to cater to the join table.

Could you let me know if I have missed out something that I am not aware of ?
Tks.

You need to add your entity mappings to the post so we can better understand your domain model.

Here’s the entity mappings:

@Entity (name = "Subject")
@Table(name = "subject")
public class Subject  implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7607227309942205498L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int subject_id;
	
	private String subject;
		
	@ManyToOne	
	private Tutor tutor;

	public Subject() {
		// TODO Auto-generated constructor stub
	}
	
	public Subject(String subject){
		this.subject = subject;
	}
	
	@JoinTable(name="tutor_id", joinColumns=@JoinColumn(name="subject_id"))
	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public Tutor getTutor() {
		return tutor;
	}


	public void setTutor(Tutor tutor) {
		this.tutor = tutor;
	}


	public void setSubject_id(int subject_id) {
		this.subject_id = subject_id;
	}
@Entity (name = "Tutor")
@Table(name = "tutor")
public class Tutor implements Serializable{
	
	public Tutor() {}
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	
	@Id
	@GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY) 
	@Column(name="tutor_id")
	private int tutor_id;	
	
	@OneToMany(mappedBy = "tutor", cascade = CascadeType.ALL, orphanRemoval = true)
	private List<Subject>subjects = new ArrayList<>();
	
	
	//private Subject subject;
	
	public Tutor(Tutor tutor){	
		
		this.Name = tutor.Name;
		this.NRIC = tutor.NRIC;
		this.gender = tutor.gender;
		this.subjects = tutor.subjects; // subjects
		.....and so on and so for...
	}
	
	public Tutor Name(String Name) {
        this.Name = Name;
        return this;
    }
		
	
	 
	@Column(name="tutorName")
	@NotNull
	private String Name;	
	
	//The owner side is the side which Hibernate looks at to know which association exists - the one that dun have mapped by
	
	public List<Subject>getSubjects(){
		return subjects;
	}
	
	public void addSubject(Subject subject){ 
		subjects.add(subject);
		subject.setTutor(this);	
	}
	
	public void removeSubject(Subject subject){
		subjects.remove(subject);
		subject.setTutor(null);
	}
	
	public int getTutor_id() {
		return tutor_id;
	}
	public int setTutor_id(int tutor_id) {
		return this.tutor_id = tutor_id;
	}
	public String getName() {
		return Name;
	}
	public void setName(String Name) {		
		this.Name = Name;
	
	@Override
	public boolean equals (Object o){
		if (this == o){
			return true;			
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}
		Tutor tutor = (Tutor)o;
		//Subject subject = (Subject)o;
		return Objects.equals(tutor_id, tutor.tutor_id)&&
				Objects.equals(NRIC, tutor.NRIC) &&
				Objects.equals(Name, tutor.Name) &&
				Objects.equals(gender, tutor.gender) &&
				Objects.equals(address1, tutor.address1) &&
				Objects.equals(address2, tutor.address2) &&
				Objects.equals(zipcode, tutor.zipcode) &&
				Objects.equals(age, tutor.age) &&
				Objects.equals(qualification, tutor.qualification) &&
				Objects.equals(qualificationDetail, tutor.qualificationDetail) &&
				Objects.equals(contactNo, tutor.contactNo) &&
				Objects.equals(email, tutor.email) &&
				Objects.equals(budget, tutor.budget) &&
				Objects.equals(remark, tutor.remark);
			//	Objects.equals(subject, subject.getSubjMany());// should I have this ?
	}
	
	@Override
	public String toString() {
		return "Tutor [tutor_id=" + tutor_id + ", Name=" + Name + ", NRIC=" + NRIC + ", gender=" + gender
				+ ", address1=" + address1 + ", address2=" + address2 + ", zipcode=" + zipcode + ", age=" + age
				+ ", qualification=" + qualification + ", qualificationDetail=" + qualificationDetail + ", contactNo="
				+ contactNo + ", email=" + email + ", budget=" + budget + ", remark=" + remark + ", subject=" + subjects
				+ "]";
	}

	
}

I just added in the JoinTable but it’s still not working. I hope you can tell me if there is anything amiss. Tks.

This mapping is wrong:

@JoinTable is for associations not for basic properties.

Now, if you auto-generated the schema, the mapping will work.

The problem is that you have a database schema that does not match with the entity mappings. That’s because there is a hi5s.subject_tutor in the database which is not present in your entity mappings.

Most likely that you want to use a unidirectional association with a join table. So, try this mapping instead:

@Entity (name = "Tutor")
@Table(name = "tutor")
public class Tutor implements Serializable{
	
	public Tutor() {}
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	
	@Id
	@GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY) 
	@Column(name="tutor_id")
	private int tutor_id;	
	
	@OneToMany
	@JoinTable(name="tutor_id", joinColumns=@JoinColumn(name="subject_id"))
	private List<Subject> subjects = new ArrayList<>();
		
	public Tutor(Tutor tutor){	
		
		this.Name = tutor.Name;
		this.NRIC = tutor.NRIC;
		this.gender = tutor.gender;
		this.subjects = tutor.subjects; // subjects
		.....and so on and so for...
	}
	
	public Tutor Name(String Name) {
        this.Name = Name;
        return this;
    }
		
	
	 
	@Column(name="tutorName")
	@NotNull
	private String Name;	
	
	//The owner side is the side which Hibernate looks at to know which association exists - the one that dun have mapped by
	
	public List<Subject>getSubjects(){
		return subjects;
	}
	
	public void addSubject(Subject subject){ 
		subjects.add(subject);
	}
	
	public void removeSubject(Subject subject){
		subjects.remove(subject);
	}
	
	public int getTutor_id() {
		return tutor_id;
	}
	public int setTutor_id(int tutor_id) {
		return this.tutor_id = tutor_id;
	}
	public String getName() {
		return Name;
	}
	public void setName(String Name) {		
		this.Name = Name;
	
	@Override
	public boolean equals (Object o){
		if (this == o){
			return true;			
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}
		Tutor tutor = (Tutor)o;
		//Subject subject = (Subject)o;
		return Objects.equals(tutor_id, tutor.tutor_id)&&
				Objects.equals(NRIC, tutor.NRIC) &&
				Objects.equals(Name, tutor.Name) &&
				Objects.equals(gender, tutor.gender) &&
				Objects.equals(address1, tutor.address1) &&
				Objects.equals(address2, tutor.address2) &&
				Objects.equals(zipcode, tutor.zipcode) &&
				Objects.equals(age, tutor.age) &&
				Objects.equals(qualification, tutor.qualification) &&
				Objects.equals(qualificationDetail, tutor.qualificationDetail) &&
				Objects.equals(contactNo, tutor.contactNo) &&
				Objects.equals(email, tutor.email) &&
				Objects.equals(budget, tutor.budget) &&
				Objects.equals(remark, tutor.remark);
			//	Objects.equals(subject, subject.getSubjMany());// should I have this ?
	}
	
	@Override
	public String toString() {
		return "Tutor [tutor_id=" + tutor_id + ", Name=" + Name + ", NRIC=" + NRIC + ", gender=" + gender
				+ ", address1=" + address1 + ", address2=" + address2 + ", zipcode=" + zipcode + ", age=" + age
				+ ", qualification=" + qualification + ", qualificationDetail=" + qualificationDetail + ", contactNo="
				+ contactNo + ", email=" + email + ", budget=" + budget + ", remark=" + remark + ", subject=" + subjects
				+ "]";
	}
	
}

And the `Subject` looks like this:

```
@Entity (name = "Subject")
@Table(name = "subject")
public class Subject  implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7607227309942205498L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int subject_id;
	
	private String subject;

	public Subject() {
		// TODO Auto-generated constructor stub
	}
	
	public Subject(String subject){
		this.subject = subject;
	}
	
	public String getSubject() {
		return subject;
	}

	public void setSubject_id(int subject_id) {
		this.subject_id = subject_id;
	}
	
}
```

Hi vlad,

You advised me to use Bidirectional long ago.

And then I was fighting with millions of issue - harddisk crash, re-do my entire project, debugging problem with Eclipse that now then I can come back.

On hindsight, I should not put in the Join table inside the code I showed you cos I was merely trying to follow a stackoverlow person suggestion but still adding that table is not helpful.

Luckily, i have marked the page of your book when you last told me which one to use.

In this case, could you let me know what should be the entity mappings to make things work ?

Thanks again.

Karen

Yes, you should use bidirectional.

But to do so, you must have a proper one-to-many database table relationship as well.

If you have a join table in the database, you won’t be able to use a bidirectional association which only requires a FK on the child table.

Just generate the schema with Hibernate hbm2ddl and observe the schema for when you are using a bidirectional association. Then, compare to the one you used which had a join table.

Hi Vlad,

Just to check my understanding of your message is correct. So, you are saying I deleted all my database in MySQL and let hbm2ddl do the job ?

So, I will change this to create instead of update ?

property name=“hibernate.hbm2ddl.auto”>update

Is it correct?

Or are you saying I remove my database schema tutor_subject (the join table) inside MySQL ?

Don’t delete de old schema if you need its data.

You can create the new schema in a new catalog to know what DB tables Hibernate needs.

Then, you can either keep the new catalog or use it as a reference to modify the old one.

Good idea. Tks Vlad…

I just read about flyway and lisquidbase…I wonder if I need to incorporate either plug in to make life easier ?

You can use hbm2ddl to generate the initial schema, then use Flyway for automatic migrations and to have a way to store incremental migration scripts in Git.

Read this article for more details.

Hi Vlad,

I did as you said. I created a new schema and make it default and changed all my connection name to the new schema name.

And then in my hibernate.cfg.xml file, I made it use create to see the new tables generated or required.

But, Tomcat just keep reading the old schema.

Is there a cache that I have to clear somewhere ?

There is no cache. Probably you haven’t deployed the new jar. However, you can easily find the answer if you debug your application and check the Driver URL value.

Tks vlad. I did a maven update and it’s running ok now.

I managed to find out the tables that are created but then there is no join table at all?

Can I know if I need to add in the hibernate.cfg.xml the model should include tutor_subject and there is no need to create a class (I think this must be stupidest thinking) or I must create one or what ?

Anyway, here’s the stacktrace and I hope you can point out to me what’s wrong cos the tutor_id actually goes into the subject table.

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2480) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2438) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:845) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:745) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	... 41 more
Hibernate: drop table if exists subject
Hibernate: drop table if exists tutor
Hibernate: drop table if exists user
Hibernate: create table subject (subject_id integer not null auto_increment, subject varchar(255), tutor_id integer, primary key (subject_id)) engine=InnoDB
INFO  [http-nio-8080-exec-4]: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@6c46c0a0] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
Hibernate: create table tutor (tutor_id integer not null auto_increment, tutorNRIC varchar(255), tutorName varchar(255), tutorAddress1 varchar(255), tutorAddress2 varchar(255), tutorAge integer, tutorRates varchar(255), tutorContactNo varchar(255), tutorEmail varchar(255), tutorGender varchar(255), tutorQualification varchar(255), tutorQualificationDetail varchar(255), tutorRemarks varchar(255), zipcode varchar(255), primary key (tutor_id)) engine=InnoDB
Hibernate: create table user (id tinyblob not null auto_increment, city varchar(255), email varchar(255), phone varchar(255), userPass tinyblob, primary key (id)) engine=InnoDB
WARN  [http-nio-8080-exec-4]: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440) [hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424) [hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315) [hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166) [hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135) [hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121) [hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155) [hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) [hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309) [hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452) [hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	at util.HibernateUtil.getSessionFactory(HibernateUtil.java:38) [classes/:?]
	at Business.RegisterService.register(RegisterService.java:26) [classes/:?]
	at controller.tutorController.doPost(tutorController.java:90) [classes/:?]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) [servlet-api.jar:?]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) [servlet-api.jar:?]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:9.0.4]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:9.0.4]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) [tomcat-websocket.jar:9.0.4]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:9.0.4]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:9.0.4]
	at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71) [log4j-web-2.7.jar:2.7]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:9.0.4]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:9.0.4]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) [catalina.jar:9.0.4]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:9.0.4]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [catalina.jar:9.0.4]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:9.0.4]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:9.0.4]
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651) [catalina.jar:9.0.4]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:9.0.4]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [catalina.jar:9.0.4]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:417) [tomcat-coyote.jar:9.0.4]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:9.0.4]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754) [tomcat-coyote.jar:9.0.4]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376) [tomcat-coyote.jar:9.0.4]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:9.0.4]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_161]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_161]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:9.0.4]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_161]
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Incorrect column specifier for column 'id'
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_161]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_161]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_161]
	at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_161]
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.Util.getInstance(Util.java:408) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2480) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2438) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:845) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:745) ~[mysql-connector-java-5.1.45-bin.jar:5.1.45]
	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final]
	... 40 more
Hibernate: alter table subject add constraint FK2w3flt767mjg2gh2xdrlampkv foreign key (tutor_id) references tutor (tutor_id)
INFO  [http-nio-8080-exec-4]: HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@3ab0f951'
INFO  [http-nio-8080-exec-4]: SessionFactory created.
INFO  [http-nio-8080-exec-4]: this is an error
java.lang.IllegalStateException: Transaction already active
	at org.hibernate.engine.transaction.internal.TransactionImpl.begin(TransactionImpl.java:52)
	at Business.RegisterService.isTutorExists(RegisterService.java:111)
	at Business.RegisterService.register(RegisterService.java:30)
	at controller.tutorController.doPost(tutorController.java:90)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:417)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
INFO  [http-nio-8080-exec-4]: this is an error message
java.lang.IllegalStateException: Transaction already active
	at org.hibernate.engine.transaction.internal.TransactionImpl.begin(TransactionImpl.java:52)
	at Business.RegisterService.register(RegisterService.java:35)
	at controller.tutorController.doPost(tutorController.java:90)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:417)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
java.lang.IllegalStateException: Transaction already active
	at org.hibernate.engine.transaction.internal.TransactionImpl.begin(TransactionImpl.java:52)
	at Business.RegisterService.insert(RegisterService.java:84)
	at controller.tutorController.doPost(tutorController.java:91)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:417)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
INFO  [http-nio-8080-exec-4]: tutor and subjects added

There must be something wrong with the code that even though the form got thru but no data actually entered the database right ?

The DDL for this table:

create table user (id tinyblob not null auto_increment, city varchar(255), email varchar(255), phone varchar(255), userPass tinyblob, primary key (id)) engine=InnoDB

Throws:

Incorrect column specifier for column 'id'

Which makes sense since an AUTO_INCREMENT column should be an INT or BIGINT, not a tinyblob which is meant for binary content (e.g. images).

Getting from one exception to another is a good indication that it’s about time you start reading the Hibernate User Guide.

Hibernate is tricky if you don’t know how to use it.

Cheers and enjoy reading the documentation.