java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • {code:java} import javax.persistence.Entity; import javax.persistence.Id; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.Environment; import org.hibernate.tool.hbm2ddl.SchemaUpdate; import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; @Entity class My { @Id public int getId() { return 0; } public void setId(final int _id) { } } public class Test { public static void main(String[] args) { MysqlDataSource ds = new MysqlDataSource(); ds.setUrl("jdbc:mysql://192.168.1.247/trongtest?user=root"); new SchemaUpdate((MetadataImplementor) new MetadataSources(new StandardServiceRegistryBuilder() .applySetting(Environment.DATASOURCE, ds).build()) .addAnnotatedClass( My.class ) .buildMetadata()).execute(true, true); } } {code} Running this code with an existing schema with an existing table name differing only in lower/uppercase (for example with create table my(id int); create table My(id int)) results in: {code:java} Exception in thread "main" java.lang.NullPointerException at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.processGetTableResults(InformationExtractorJdbcDatabaseMetaDataImpl.java:352) at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.locateTableInNamespace(InformationExtractorJdbcDatabaseMetaDataImpl.java:315) at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getTable(InformationExtractorJdbcDatabaseMetaDataImpl.java:210) at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.getTableInformation(DatabaseInformationImpl.java:105) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:129) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:59) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:129) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:97) at Test.main(Test.java:33) {code} I only accidently got this problem after I got my schemas and tables randomly mixed up. Not a real problem that I encountered.
    via by Trong Dinh,
  • {code:java} import javax.persistence.Entity; import javax.persistence.Id; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.Environment; import org.hibernate.tool.hbm2ddl.SchemaUpdate; import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; @Entity class My { @Id public int getId() { return 0; } public void setId(final int _id) { } } public class Test { public static void main(String[] args) { MysqlDataSource ds = new MysqlDataSource(); ds.setUrl("jdbc:mysql://192.168.1.247/trongtest?user=root"); new SchemaUpdate((MetadataImplementor) new MetadataSources(new StandardServiceRegistryBuilder() .applySetting(Environment.DATASOURCE, ds).build()) .addAnnotatedClass( My.class ) .buildMetadata()).execute(true, true); } } {code} Running this code with an existing schema with an existing table name differing only in lower/uppercase (for example with create table my(id int); create table My(id int)) results in: {code:java} Exception in thread "main" java.lang.NullPointerException at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.processGetTableResults(InformationExtractorJdbcDatabaseMetaDataImpl.java:352) at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.locateTableInNamespace(InformationExtractorJdbcDatabaseMetaDataImpl.java:315) at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getTable(InformationExtractorJdbcDatabaseMetaDataImpl.java:210) at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.getTableInformation(DatabaseInformationImpl.java:105) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:129) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:59) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:129) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:97) at Test.main(Test.java:33) {code} I only accidently got this problem after I got my schemas and tables randomly mixed up. Not a real problem that I encountered.
    via by Trong Dinh,
    • java.lang.NullPointerException at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.processGetTableResults(InformationExtractorJdbcDatabaseMetaDataImpl.java:352) at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.locateTableInNamespace(InformationExtractorJdbcDatabaseMetaDataImpl.java:315) at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getTable(InformationExtractorJdbcDatabaseMetaDataImpl.java:210) at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.getTableInformation(DatabaseInformationImpl.java:105) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:129) at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:59) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:129) at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:97) at Test.main(Test.java:33)
    No Bugmate found.