0

I am working with a Spring Boot application . I have faced some issue related to org.hibernate.HibernateException: Missing column: auth_password in medxlabpro.appsettings

I have column in my PoJo class authpassword not auth_password. So why this type of issue coming in my application . Anyone can help me please. I have added JPA configuration and Log.

As per my concern i guess it is coming due to configuration mistake.

generate-ddl: false hibernate: ddl-auto: validate

:: Spring Boot ::        (v1.2.1.RELEASE)

2016-06-21 19:31:52.733  INFO 8196 --- [           main] org.sam.application.Application          : Starting Application on DESKTOP-JIBLNR1 with PID 8196 (C:\LabSystem\Scheduler\target\classes started by Sitansu in C:\LabSystem\Scheduler)
2016-06-21 19:31:52.805  INFO 8196 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@bd4dc25: startup date [Tue Jun 21 19:31:52 IST 2016]; root of context hierarchy
2016-06-21 19:31:53.912  INFO 8196 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.scheduling.annotation.SchedulingConfiguration' of type [class org.springframework.scheduling.annotation.SchedulingConfiguration$$EnhancerBySpringCGLIB$$960de3bc] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-06-21 19:31:53.948  INFO 8196 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.scheduling.annotation.ProxyAsyncConfiguration' of type [class org.springframework.scheduling.annotation.ProxyAsyncConfiguration$$EnhancerBySpringCGLIB$$3cdcd8e2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-06-21 19:31:54.435  INFO 8196 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-06-21 19:31:54.463  INFO 8196 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2016-06-21 19:31:54.560  INFO 8196 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {4.3.7.Final}
2016-06-21 19:31:54.561  INFO 8196 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2016-06-21 19:31:54.563  INFO 8196 --- [           main] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2016-06-21 19:31:54.900  INFO 8196 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2016-06-21 19:31:55.677  INFO 8196 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2016-06-21 19:31:55.687  INFO 8196 --- [           main] o.h.e.jdbc.internal.LobCreatorBuilder    : HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
2016-06-21 19:31:56.056  INFO 8196 --- [           main] o.h.h.i.ast.ASTQueryTranslatorFactory    : HHH000397: Using ASTQueryTranslatorFactory
2016-06-21 19:31:56.592  INFO 8196 --- [           main] o.h.tool.hbm2ddl.SchemaValidator         : HHH000229: Running schema validator
2016-06-21 19:31:56.593  INFO 8196 --- [           main] o.h.tool.hbm2ddl.SchemaValidator         : HHH000102: Fetching database metadata
2016-06-21 19:31:56.628  INFO 8196 --- [           main] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000261: Table found: medxlabpro.appsettings
2016-06-21 19:31:56.629  INFO 8196 --- [           main] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000037: Columns: [hl7ftphostname, hl7ftppassword, clientcode, desktopheight1, desktopheight2, newordereligipdfneeded, billingdays, receiptno, defaultpagesize, desktopheight3, postingbatchno, desktopheight4, desktopheight5, id, edibatchno, desktopheight6, datarootfolder, desktopheight7, desktopheight8, claimno, hl7ftpfolder, hl7ftpusername, neworderorderpdfneeded, authpassword, desktoppagesize8, hl7ftpport, desktoppagesize6, neworderresultpdfneeded, desktoppagesize7, desktoppagesize4, desktoppagesize5, versionno, desktoppagesize2, desktoppagesize3, desktoppagesize1, invoiceno]
2016-06-21 19:31:56.636  WARN 8196 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Missing column: auth_password in abcdpro.appsettings
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
    at org.sam.application.Application.main(Application.java:33)
Caused by: org.hibernate.HibernateException: Missing column: auth_password in abcdpro.appsettings
    at org.hibernate.mapping.Table.validateColumns(Table.java:365)
    at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1338)
    at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:525)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844)
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)

JPA configuration:

  jpa:
    generate-ddl: false
    hibernate:
      ddl-auto: validate
    database: MYSQL
    show-sql: true

How can i fix this anyone can help me please ?

Thanks Sitansu

1
  • you have a message that some column is missing when it expects it, yet don't post the actual class that maps on to that table (abcdpro.appsettings)! Would have thought that if you posted one thing and only one thing it would be that class! Commented Jun 21, 2016 at 15:01

2 Answers 2

1

By default Spring Boot uses SpringNamingStrategy. This strategy generates underscores in table and field names. So for field authPassword the strategy generates auth_password column name.

If you want to map entity fields to camel case column names you can use org.hibernate.cfg.EJB3NamingStrategy or implement your own.

You can specify a naming strategy in application.properties

spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
Sign up to request clarification or add additional context in comments.

1 Comment

how to configure EJB3NamingStrategy .Actually i have no idea about this.
0

I have column in my PoJo class authpassword not auth_password.

Easy solution could be:

add @Column(name="auth_password") to your authpassword field.

Then it should work

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.