问:
How to maintain, Hibernate ID Sequence with MySql.?
Please help me to sort out this issue.I tried to make a sequence with mySql.
here is my Domain Class

```<code>@Entity
@Table(name="PATIENT")
public class Patient {
    @Id
    @Column(name="id", nullable=false)
    @SequenceGenerator(name="patient_seq", sequenceName="patient_id_seq")
    @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="patient_seq")
    private Integer id;

    @Column private String name;
    @Column private Integer age;
    @Column private String illness;
</code>```

here shows my hibernate properties

```<code>jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test
jdbc.username=root
jdbc.password=

hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update
hibernate.generate_statistics=true
</code>```

and here shows my output error

```ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsControllers': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.priyan.patients.ContactsDAO com.priyan.patients.ContactsControllers.contactsDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.priyan.patients.ContactsDAO com.priyan.patients.ContactsControllers.contactsDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
    ... 28 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
    ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
    ... 41 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
    ... 43 more
Caused by: org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:132)
    at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:230)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 53 more
Caused by: org.hibernate.MappingException: Dialect does not support sequences
    at org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:619)
    at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:88)
    at org.hibernate.id.SequenceHiLoGenerator.configure(SequenceHiLoGenerator.java:66)
    at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:127)
    ... 62 more
Oct 29, 2013 10:40:47 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsControllers': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.priyan.patients.ContactsDAO com.priyan.patients.ContactsControllers.contactsDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.priyan.patients.ContactsDAO com.priyan.patients.ContactsControllers.contactsDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
    ... 28 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
    ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
    ... 41 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
    ... 43 more
Caused by: org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:132)
    at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:230)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 53 more
Caused by: org.hibernate.MappingException: Dialect does not support sequences
    at org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:619)
    at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:88)
    at org.hibernate.id.SequenceHiLoGenerator.configure(SequenceHiLoGenerator.java:66)
    at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:127)
    ... 62 more
```

答:
In Spring Boot, it throws an error saying "org.hibernate.dialect.MySQL5Dialect does not support pooled sequences". Because Mysql doesn't support sequences. This error has been occurred because you have used following line in your entity class.

```<code> @SequenceGenerator(name="patient_seq", sequenceName="patient_id_seq")
    @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="patient_seq")
</code>```

You just have to replace above lines of code with,

```<code>@GeneratedValue(strategy=GenerationType.AUTO)
</code>```

Make sure that your application.properties file has following line.

```<code>spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
</code>```

Body:
Please help me to sort out this issue.I tried to make a sequence with mySql.
here is my Domain Class

@Entity
@Table(name="PATIENT")
public class Patient {
    @Id
    @Column(name="id", nullable=false)
    @SequenceGenerator(name="patient_seq", sequenceName="patient_id_seq")
    @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="patient_seq")
    private Integer id;

    @Column private String name;
    @Column private Integer age;
    @Column private String illness;

here shows my hibernate properties

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test
jdbc.username=root
jdbc.password=

hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update
hibernate.generate_statistics=true

and here shows my output error

ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsControllers': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.priyan.patients.ContactsDAO com.priyan.patients.ContactsControllers.contactsDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.priyan.patients.ContactsDAO com.priyan.patients.ContactsControllers.contactsDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
    ... 28 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
    ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
    ... 41 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
    ... 43 more
Caused by: org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:132)
    at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:230)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 53 more
Caused by: org.hibernate.MappingException: Dialect does not support sequences
    at org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:619)
    at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:88)
    at org.hibernate.id.SequenceHiLoGenerator.configure(SequenceHiLoGenerator.java:66)
    at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:127)
    ... 62 more
Oct 29, 2013 10:40:47 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsControllers': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.priyan.patients.ContactsDAO com.priyan.patients.ContactsControllers.contactsDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.priyan.patients.ContactsDAO com.priyan.patients.ContactsControllers.contactsDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
    ... 28 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
    ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.priyan.patients.ContactsDAO.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
    ... 41 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
    ... 43 more
Caused by: org.hibernate.MappingException: could not instantiate id generator [entity-name=com.priyan.patients.Patient]
    at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:132)
    at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:230)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 53 more
Caused by: org.hibernate.MappingException: Dialect does not support sequences
    at org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:619)
    at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:88)
    at org.hibernate.id.SequenceHiLoGenerator.configure(SequenceHiLoGenerator.java:66)
    at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:127)
    ... 62 more

Body:
In Spring Boot, it throws an error saying "org.hibernate.dialect.MySQL5Dialect does not support pooled sequences". Because Mysql doesn't support sequences. This error has been occurred because you have used following line in your entity class.

 @SequenceGenerator(name="patient_seq", sequenceName="patient_id_seq")
    @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="patient_seq")

You just have to replace above lines of code with,

@GeneratedValue(strategy=GenerationType.AUTO)

Make sure that your application.properties file has following line.

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect


来源: stackexchange

问:
passing dynamic parameter in curl from seperate file in bash shell
In a bash script i want to get date dynamically and send it along with the
curl call.

i have got the date from the user in the bash script
and in the script am making the below curl call. am already passing the request params using a separate file as below. How do i pass the date?
 i have tried like $date, but it is not working, even tried "'$date'".

The below is my curl call:

```<code>curl -O -X POST -H "Content-Type: application/json" -d@formparams.json --url http://test.com
</code>```

Contents of form params json: it has more than 10 params for simplicity iam including only two

```<code>{"params":"{"HOSTS:":"1",date=$date}}
</code>```

in the above i have added date.

But the date is not replaced.
Any help is appreciated.

答:
use this json for pass dynamic parameter</p>

```<code>{"params":"{"HOSTS:":"1",date="'$date'"}}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
In a bash script i want to get date dynamically and send it along with the
curl call.

i have got the date from the user in the bash script
and in the script am making the below curl call. am already passing the request params using a separate file as below. How do i pass the date?
 i have tried like $date, but it is not working, even tried "'$date'".

The below is my curl call:

curl -O -X POST -H "Content-Type: application/json" -d@formparams.json --url http://test.com

Contents of form params json: it has more than 10 params for simplicity iam including only two

{"params":"{"HOSTS:":"1",date=$date}}

in the above i have added date.

But the date is not replaced.
Any help is appreciated.

Body:
use this json for pass dynamic parameter

{"params":"{"HOSTS:":"1",date="'$date'"}}


问:
For loop skips duplicate values
so I have a function which gets an array of objects from its parameter. In this example, there are 4 objects inside the array. The object contains the keys:

```<code>{ reportedBy: String, reason: String}
</code>```

So the input array is:

```<code>[{reportedBy: "58dd0c8c23ffea1bb767614f", reason: "User insulted me"}, {reportedBy: "58dd0c8c53faea1bb88379a", reason: "User insulted me"}, {reportedBy: "58dd0c8c23ffea1bb767614f", reason: "User violated against FAQs"}, {reportedBy: "58dd0c8c53fabb356fab", reason: "Uses a fake account"}]
</code>```

So in this example, I have this object four times in the array. The keys can have duplicate values (like the IDs and the reason), so the reportedBy String can exist multiple times, just not together with the same reason String (That's because a user can report an item for every reason once). I just simply wanted to get all the 4 reportedBy and reason values. So I used a for loop:

```<code>for (var i = 0; i < object.length; i++) {
   console.log(object[i].reason);
   console.log(object[i].reportedBy);
}
</code>```

object is the parameter of the function and contains the 4 objects. But the problem is that this only gives me back all the values once , and no duplicates. And I just don't get why, because this works:

```<code>console.log(object[0].reason);
console.log(object[1].reason);
console.log(object[2].reason);
console.log(object[3].reason);
</code>```

I even tried to use a for loop that iterates from 0 to 4, but I still didn't get all the 4 values, only 3 because two are the same. Is it normal that the for loop skips duplicate values?

答:
It worked for me. Please see the snippet below for reference.

Please create snippet if it wont work for you. There is no issue with for loop.

It is also working for the array you have provided.

array=[{reportedBy: "58dd0c8c23ffea1bb767614f", reason: "User insulted me"}, {reportedBy: "58dd0c8c53faea1bb88379a", reason: "User insulted me"}, {reportedBy: "58dd0c8c23ffea1bb767614f", reason: "User violated against FAQs"}, {reportedBy: "58dd0c8c53fabb356fab", reason: "Uses a fake account"}];

for (var i = 0; i < array.length; i++) {
   console.log(array[i].reason);
   console.log(array[i].reportedBy);
}```

Title: For loop skips duplicate values

Body:
so I have a function which gets an array of objects from its parameter. In this example, there are 4 objects inside the array. The object contains the keys:

{ reportedBy: String, reason: String}

So the input array is:

[{reportedBy: "58dd0c8c23ffea1bb767614f", reason: "User insulted me"}, {reportedBy: "58dd0c8c53faea1bb88379a", reason: "User insulted me"}, {reportedBy: "58dd0c8c23ffea1bb767614f", reason: "User violated against FAQs"}, {reportedBy: "58dd0c8c53fabb356fab", reason: "Uses a fake account"}]

So in this example, I have this object four times in the array. The keys can have duplicate values (like the IDs and the reason), so the reportedBy String can exist multiple times, just not together with the same reason String (That's because a user can report an item for every reason once). I just simply wanted to get all the 4 reportedBy and reason values. So I used a for loop:

for (var i = 0; i < object.length; i++) {
   console.log(object[i].reason);
   console.log(object[i].reportedBy);
}

object is the parameter of the function and contains the 4 objects. But the problem is that this only gives me back all the values once , and no duplicates. And I just don't get why, because this works:

console.log(object[0].reason);
console.log(object[1].reason);
console.log(object[2].reason);
console.log(object[3].reason);

I even tried to use a for loop that iterates from 0 to 4, but I still didn't get all the 4 values, only 3 because two are the same. Is it normal that the for loop skips duplicate values?


问:
Android device is not connected to USB for debugging (Android studio)
I am trying to debug my application using a real device instead on the emulator. When I try to connect, it gives me the message:

USB device not found

I tried to unplug and plug it again, but it did not work. And I have also enabled USB debugging and unknown sources options in my device.

Any help is appreciated!

Thanks!

答: Galaxy S7, I had to go to Settings, Developer Options and allow USB Debugging. This asked to approve computer it was attached to and it showed up instantly. </p>


问:
Choosing an attractive linear scale for a graph's Y Axis
I'm writing a bit of code to display a bar (or line) graph in our software.  Everything's going fine.  The thing that's got me stumped is labeling the Y axis.

The caller can tell me how finely they want the Y scale labeled, but I seem to be stuck on exactly what to label them in an "attractive" kind of way.  I can't describe "attractive", and probably neither can you, but we know it when we see it, right?

So if the data points are:

```<code>   15, 234, 140, 65, 90
</code>```

And the user asks for 10 labels on the Y axis, a little bit of finagling with paper and pencil comes up with:

```<code>  0, 25, 50, 75, 100, 125, 150, 175, 200, 225, 250
</code>```

So there's 10 there (not including 0), the last one extends just beyond the highest value (234 < 250), and it's a "nice" increment of 25 each.  If they asked for 8 labels, an increment of 30 would have looked nice:

```<code>  0, 30, 60, 90, 120, 150, 180, 210, 240
</code>```

Nine would have been tricky.  Maybe just have used either 8 or 10 and call it close enough would be okay.  And what to do when some of the points are negative?

I can see Excel tackles this problem nicely.

Does anyone know a general-purpose algorithm (even some brute force is okay) for solving this?  I don't have to do it quickly, but it should look nice.

答:
The answer by Toon Krijthe does work most of the time. But sometimes it will produce excess number of ticks. It won't work with negative numbers as well. The overal approach to the problem is ok but there is a better way to handle this. The algorithm you want to use will depend on what you really want to get.  Below I'm presenting you my code which I used in my JS Ploting library. I've tested it and it always works (hopefully ;) ). Here are the major steps:

get global extremas xMin and xMax (inlucde all the plots you want to print in the algorithm )

calculate range between xMin and xMax

calculate the order of magnitude of your range

calculate tick size by dividing range by number of ticks minus one

this one is optional. If you want to have zero tick allways printed you use tick size to calculate number of positive and negative ticks. Total number of ticks will be their sum + 1 (the zero tick)

this one is not needed if you have zero tick allways printed. Calculate lower and upper bound but remember to center the plot

Lets start. First the basic calculations

```<code>    var range = Math.abs(xMax - xMin); //both can be negative
    var rangeOrder = Math.floor(Math.log10(range)) - 1;
    var power10 = Math.pow(10, rangeOrder);
    var maxRound = (xMax > 0) ? Math.ceil(xMax / power10) : Math.floor(xMax / power10);
    var minRound = (xMin < 0) ? Math.floor(xMin / power10) : Math.ceil(xMin / power10);
</code>```

I round minimum and maximum values to be 100% sure that my plot will cover all the data. It is also very important to floor log10 of range wheter or not it is negative and substract 1 later. Otherwise your algorithm won't work for numbers that are lesser than one.

```<code>    var fullRange = Math.abs(maxRound - minRound);
    var tickSize = Math.ceil(fullRange / (this.XTickCount - 1));

    //You can set nice looking ticks if you want
    //You can find exemplary method below
    tickSize = this.NiceLookingTick(tickSize);

    //Here you can write a method to determine if you need zero tick
    //You can find exemplary method below
    var isZeroNeeded = this.HasZeroTick(maxRound, minRound, tickSize);
</code>```

I use "nice looking ticks" to avoid ticks like 7, 13, 17 etc. Method I use here is pretty simple. It is also nice to have zeroTick when needed. Plot looks much more professional this way. You will find all the methods at the end of this answer.

Now you have to calculate upper and lower bounds. This is very easy with zero tick but requires a little bit more effort in other case. Why? Because we want to center the plot within upper and lower bound nicely. Have a look at my code. Some of the variables are defined outside of this scope and some of them are properties of an object in which whole presented code is kept.

```<code>    if (isZeroNeeded) {

        var positiveTicksCount = 0;
        var negativeTickCount = 0;

        if (maxRound != 0) {

            positiveTicksCount = Math.ceil(maxRound / tickSize);
            XUpperBound = tickSize * positiveTicksCount * power10;
        }

        if (minRound != 0) {
            negativeTickCount = Math.floor(minRound / tickSize);
            XLowerBound = tickSize * negativeTickCount * power10;
        }

        XTickRange = tickSize * power10;
        this.XTickCount = positiveTicksCount - negativeTickCount + 1;
    }
    else {
        var delta = (tickSize * (this.XTickCount - 1) - fullRange) / 2.0;

        if (delta % 1 == 0) {
            XUpperBound = maxRound + delta;
            XLowerBound = minRound - delta;
        }
        else {
            XUpperBound =  maxRound + Math.ceil(delta);
            XLowerBound =  minRound - Math.floor(delta);
        }

        XTickRange = tickSize * power10;
        XUpperBound = XUpperBound * power10;
        XLowerBound = XLowerBound * power10;
    }
</code>```

And here are methods I mentioned before which you can write by yourself but you can also use mine

```<code>this.NiceLookingTick = function (tickSize) {

    var NiceArray = [1, 2, 2.5, 3, 4, 5, 10];

    var tickOrder = Math.floor(Math.log10(tickSize));
    var power10 = Math.pow(10, tickOrder);
    tickSize = tickSize / power10;

    var niceTick;
    var minDistance = 10;
    var index = 0;

    for (var i = 0; i < NiceArray.length; i++) {
        var dist = Math.abs(NiceArray[i] - tickSize);
        if (dist < minDistance) {
            minDistance = dist;
            index = i;
        }
    }

    return NiceArray[index] * power10;
}

this.HasZeroTick = function (maxRound, minRound, tickSize) {

    if (maxRound * minRound < 0)
    {
        return true;
    }
    else if (Math.abs(maxRound) < tickSize || Math.round(minRound) < tickSize) {

        return true;
    }
    else {

        return false;
    }
}
</code>```

There is only one more thing that is not included here. This is the "nice looking bounds". These are lower bounds that are numbers similar to the numbers in "nice looking ticks". For example it is better to have the lower bound starting at 5 with tick size 5 than having a plot that starts at 6 with the same tick size. But this my fired I leave it to you.

Hope it helps.
Cheers!

OwnerDisplayName: clintp

ContentLicense: CC BY-SA 2.5

Body:
I'm writing a bit of code to display a bar (or line) graph in our software.  Everything's going fine.  The thing that's got me stumped is labeling the Y axis.

The caller can tell me how finely they want the Y scale labeled, but I seem to be stuck on exactly what to label them in an "attractive" kind of way.  I can't describe "attractive", and probably neither can you, but we know it when we see it, right?

So if the data points are:

   15, 234, 140, 65, 90

And the user asks for 10 labels on the Y axis, a little bit of finagling with paper and pencil comes up with:

  0, 25, 50, 75, 100, 125, 150, 175, 200, 225, 250

So there's 10 there (not including 0), the last one extends just beyond the highest value (234 < 250), and it's a "nice" increment of 25 each.  If they asked for 8 labels, an increment of 30 would have looked nice:

  0, 30, 60, 90, 120, 150, 180, 210, 240

Nine would have been tricky.  Maybe just have used either 8 or 10 and call it close enough would be okay.  And what to do when some of the points are negative?

I can see Excel tackles this problem nicely.

Does anyone know a general-purpose algorithm (even some brute force is okay) for solving this?  I don't have to do it quickly, but it should look nice.

LastEditorDisplayName: Andrew

Body:
The answer by Toon Krijthe does work most of the time. But sometimes it will produce excess number of ticks. It won't work with negative numbers as well. The overal approach to the problem is ok but there is a better way to handle this. The algorithm you want to use will depend on what you really want to get.  Below I'm presenting you my code which I used in my JS Ploting library. I've tested it and it always works (hopefully ;) ). Here are the major steps:

get global extremas xMin and xMax (inlucde all the plots you want to print in the algorithm )

calculate range between xMin and xMax

calculate the order of magnitude of your range

calculate tick size by dividing range by number of ticks minus one

this one is optional. If you want to have zero tick allways printed you use tick size to calculate number of positive and negative ticks. Total number of ticks will be their sum + 1 (the zero tick)

this one is not needed if you have zero tick allways printed. Calculate lower and upper bound but remember to center the plot

Lets start. First the basic calculations

    var range = Math.abs(xMax - xMin); //both can be negative
    var rangeOrder = Math.floor(Math.log10(range)) - 1;
    var power10 = Math.pow(10, rangeOrder);
    var maxRound = (xMax > 0) ? Math.ceil(xMax / power10) : Math.floor(xMax / power10);
    var minRound = (xMin < 0) ? Math.floor(xMin / power10) : Math.ceil(xMin / power10);

I round minimum and maximum values to be 100% sure that my plot will cover all the data. It is also very important to floor log10 of range wheter or not it is negative and substract 1 later. Otherwise your algorithm won't work for numbers that are lesser than one.

    var fullRange = Math.abs(maxRound - minRound);
    var tickSize = Math.ceil(fullRange / (this.XTickCount - 1));

    //You can set nice looking ticks if you want
    //You can find exemplary method below
    tickSize = this.NiceLookingTick(tickSize);

    //Here you can write a method to determine if you need zero tick
    //You can find exemplary method below
    var isZeroNeeded = this.HasZeroTick(maxRound, minRound, tickSize);

I use "nice looking ticks" to avoid ticks like 7, 13, 17 etc. Method I use here is pretty simple. It is also nice to have zeroTick when needed. Plot looks much more professional this way. You will find all the methods at the end of this answer.

Now you have to calculate upper and lower bounds. This is very easy with zero tick but requires a little bit more effort in other case. Why? Because we want to center the plot within upper and lower bound nicely. Have a look at my code. Some of the variables are defined outside of this scope and some of them are properties of an object in which whole presented code is kept.

    if (isZeroNeeded) {

        var positiveTicksCount = 0;
        var negativeTickCount = 0;

        if (maxRound != 0) {

            positiveTicksCount = Math.ceil(maxRound / tickSize);
            XUpperBound = tickSize * positiveTicksCount * power10;
        }

        if (minRound != 0) {
            negativeTickCount = Math.floor(minRound / tickSize);
            XLowerBound = tickSize * negativeTickCount * power10;
        }

        XTickRange = tickSize * power10;
        this.XTickCount = positiveTicksCount - negativeTickCount + 1;
    }
    else {
        var delta = (tickSize * (this.XTickCount - 1) - fullRange) / 2.0;

        if (delta % 1 == 0) {
            XUpperBound = maxRound + delta;
            XLowerBound = minRound - delta;
        }
        else {
            XUpperBound =  maxRound + Math.ceil(delta);
            XLowerBound =  minRound - Math.floor(delta);
        }

        XTickRange = tickSize * power10;
        XUpperBound = XUpperBound * power10;
        XLowerBound = XLowerBound * power10;
    }

And here are methods I mentioned before which you can write by yourself but you can also use mine

this.NiceLookingTick = function (tickSize) {

    var NiceArray = [1, 2, 2.5, 3, 4, 5, 10];

    var tickOrder = Math.floor(Math.log10(tickSize));
    var power10 = Math.pow(10, tickOrder);
    tickSize = tickSize / power10;

    var niceTick;
    var minDistance = 10;
    var index = 0;

    for (var i = 0; i < NiceArray.length; i++) {
        var dist = Math.abs(NiceArray[i] - tickSize);
        if (dist < minDistance) {
            minDistance = dist;
            index = i;
        }
    }

    return NiceArray[index] * power10;
}

this.HasZeroTick = function (maxRound, minRound, tickSize) {

    if (maxRound * minRound < 0)
    {
        return true;
    }
    else if (Math.abs(maxRound) < tickSize || Math.round(minRound) < tickSize) {

        return true;
    }
    else {

        return false;
    }
}

There is only one more thing that is not included here. This is the "nice looking bounds". These are lower bounds that are numbers similar to the numbers in "nice looking ticks". For example it is better to have the lower bound starting at 5 with tick size 5 than having a plot that starts at 6 with the same tick size. But this my fired I leave it to you.

Hope it helps.
Cheers!


问:
How to count only 1s in SQL?
I am trying to run a report to see how many vehicles need a repair over the last month and how many need a service. As shown below, if a vehicle has had a repair, it has a 1 assigned to it, otherwise, it's a 0. This is my attempt currently and it's returning both 1 and 0s which I don't want. Any help is much appreciated.

```<code> select
   vehicles_inspections.Vehicle_ID,
   make,
   model,
   count(Repair),
   count(Service)
 from vehicles_inspections, vehicles
 where vehicles.Vehicle_ID = vehicles_inspections.Vehicle_ID
 group by Vehicle_ID
</code>```

答:
This is your existing where clause:

```<code>where vehicles.Vehicle_ID = vehicles_inspections.Vehicle_ID
</code>```

To that clause, add this:

```<code>and repair_service_complete = 0
and repair = 1
</code>```

or whatever similar filter achieves your business requirement.

Title: How to count only 1s in SQL?

Body:
I am trying to run a report to see how many vehicles need a repair over the last month and how many need a service. As shown below, if a vehicle has had a repair, it has a 1 assigned to it, otherwise, it's a 0. This is my attempt currently and it's returning both 1 and 0s which I don't want. Any help is much appreciated.

 select
   vehicles_inspections.Vehicle_ID,
   make,
   model,
   count(Repair),
   count(Service)
 from vehicles_inspections, vehicles
 where vehicles.Vehicle_ID = vehicles_inspections.Vehicle_ID
 group by Vehicle_ID

Body:
This is your existing where clause:

where vehicles.Vehicle_ID = vehicles_inspections.Vehicle_ID

To that clause, add this:

and repair_service_complete = 0
and repair = 1

or whatever similar filter achieves your business requirement.


问:
How to scale data before fitting in matlab 2016b
I use the fit() function of matlab 2016b to fit a complicate exponential function to data x,y.
The x values are very small (1e-3) and the y values are in the order of 1.

The fitting works well, if I multiply x by a constant factor 1000 to 100000.
This effect is described in the mathworks online help in section "Using Normalize or Center and Scale".

The Normalize: 'on' setting fails here (1) even with very narrow upper and lower limits.
Is the Normalize option transparent for the user, or will I have to change my boundaries after enabling it?

For now I help my self by multiplying x and correct the coefficients in the fit results afterwards.

```<code>ScalingFactor = 1000;
[xData, yData] = prepareCurveData( myx * ScalingFactor, myy );
ft = fittype(..)
[fitresult, gof] = fit( xData, yData, ft, opts );
%% now correct the results
</code>```

This does not look very elegant to me for a quite expensive software.
4 years ago there was a similar question on sx without a handy solution.

Is there a better solution today?

1) Perhaps the error message helps other users to find this question/answer some day, so I paste it here:

```<code>Error using fit>iFit (line 340)
Complex value computed by model function, fitting cannot continue.
Try using or tightening upper and lower bounds on coefficients.
</code>```

答:
You might consider placing the scaling factor inside the function itself as a fitted parameter.  For example, instead of:

```<code>scaledX = x * 1000
y = f(scaledX)
</code>```

you would instead directly fit to:

```<code>y = f(scalingFactor * x)
</code>```

so that the fitting (hopefully) finds the optimum scaling factor for you.

Body:
I use the fit() function of matlab 2016b to fit a complicate exponential function to data x,y.
The x values are very small (1e-3) and the y values are in the order of 1.

The fitting works well, if I multiply x by a constant factor 1000 to 100000.
This effect is described in the mathworks online help in section "Using Normalize or Center and Scale".

The Normalize: 'on' setting fails here (1) even with very narrow upper and lower limits.
Is the Normalize option transparent for the user, or will I have to change my boundaries after enabling it?

For now I help my self by multiplying x and correct the coefficients in the fit results afterwards.

ScalingFactor = 1000;
[xData, yData] = prepareCurveData( myx * ScalingFactor, myy );
ft = fittype(..)
[fitresult, gof] = fit( xData, yData, ft, opts );
%% now correct the results

This does not look very elegant to me for a quite expensive software.
4 years ago there was a similar question on sx without a handy solution.

Is there a better solution today?

1) Perhaps the error message helps other users to find this question/answer some day, so I paste it here:

Error using fit>iFit (line 340)
Complex value computed by model function, fitting cannot continue.
Try using or tightening upper and lower bounds on coefficients.

Body:
You might consider placing the scaling factor inside the function itself as a fitted parameter.  For example, instead of:

scaledX = x * 1000
y = f(scaledX)

you would instead directly fit to:

y = f(scalingFactor * x)

so that the fitting (hopefully) finds the optimum scaling factor for you.


问:
YouTubePlayer pod crashes when loading video ID
I am trying to do something very basic, I have an outlet that is assigned with the YouTubePlayerView class and once loading an ID, it crashes.
Why is it crashing?
I checked that the outlet is connected properly and the debugger shows that videoId is defined correctly.

code:

```<code>import UIKit
import YouTubePlayer
class InfoViewController: UIViewController {

var videoId = "Bgh9u7x8i4Y"
@IBOutlet var youtubePlayer: YouTubePlayerView!
override func viewDidLoad() {
    super.viewDidLoad()
    self.youtubePlayer.loadVideoID(videoId)
}

@IBAction func exit(_ sender: UIButton) {
    performSegue(withIdentifier: "unwindToMainFromInfo", sender: self)

}
</code>```

}

答:
Well, I am still not sure what causes the crash, I believe it is something related to the framework, and choosing the type of a UIView (and setting it as a YouTubePlayerView through the identity inspector) added in Storyboard caused a crash when trying to load the videoId.

The work around was to add the player programatically. I used a plain view in storyboard to make it easy to give my player a frame when initializing it. But otherwise programatically works smoothly.
code:

```<code>    @IBOutlet weak var viewForPlayer: UIView!
    override func viewDidLoad() {
        super.viewDidLoad()
        let frameForPlayer = viewForPlayer.frame
        let player = YouTubePlayerView(frame: frameForPlayer)
        player.loadVideoID(InstructionsVideoId)
        player.play()
        self.view.addSubview(player)
    }
</code>```

Body:
I am trying to do something very basic, I have an outlet that is assigned with the YouTubePlayerView class and once loading an ID, it crashes.
Why is it crashing?
I checked that the outlet is connected properly and the debugger shows that videoId is defined correctly.

code:

import UIKit
import YouTubePlayer
class InfoViewController: UIViewController {

var videoId = "Bgh9u7x8i4Y"
@IBOutlet var youtubePlayer: YouTubePlayerView!
override func viewDidLoad() {
    super.viewDidLoad()
    self.youtubePlayer.loadVideoID(videoId)
}

@IBAction func exit(_ sender: UIButton) {
    performSegue(withIdentifier: "unwindToMainFromInfo", sender: self)

}

}

Body:
Well, I am still not sure what causes the crash, I believe it is something related to the framework, and choosing the type of a UIView (and setting it as a YouTubePlayerView through the identity inspector) added in Storyboard caused a crash when trying to load the videoId.

The work around was to add the player programatically. I used a plain view in storyboard to make it easy to give my player a frame when initializing it. But otherwise programatically works smoothly.
code:

    @IBOutlet weak var viewForPlayer: UIView!
    override func viewDidLoad() {
        super.viewDidLoad()
        let frameForPlayer = viewForPlayer.frame
        let player = YouTubePlayerView(frame: frameForPlayer)
        player.loadVideoID(InstructionsVideoId)
        player.play()
        self.view.addSubview(player)
    }


问:
JavaScript: cloneNode vs importNode
I noticed in some code samples to seemingly different ways to clone a DOM node and append it to an existing element:

```<code>element.appendChild(something.cloneNode(true));
element.appendChild(document.importNode(something, true));
</code>```

Both have the effect of copying a node. The second version seems more verbose, and implies that the copy is actually somewhere concrete first, though it still needs to find a proper home. However, it is used by MDN and a few other as an illustration of using the template tag. Elsewhere they go for the simpler clodeNode option.

The question is: what is the benefit to using importNode over cloneNode?

答: In DOM3 and earlier, importNode was for copying nodes from other documents, cloneNode for copying within the same document. But browsers don't enforce that, so in the latest DOM standard cloneNode can be used to copy from a different document. When using DOM in other contexts, stick with the DOM3 rules.</p>

Title: JavaScript: cloneNode vs importNode

Body:
I noticed in some code samples to seemingly different ways to clone a DOM node and append it to an existing element:

element.appendChild(something.cloneNode(true));
element.appendChild(document.importNode(something, true));

Both have the effect of copying a node. The second version seems more verbose, and implies that the copy is actually somewhere concrete first, though it still needs to find a proper home. However, it is used by MDN and a few other as an illustration of using the template tag. Elsewhere they go for the simpler clodeNode option.

The question is: what is the benefit to using importNode over cloneNode?


问:
Can ICU convert codes 1-31 in CP 850?
I need to convert from UTF-8 to CP 850, and would like to support as many different combinations as possible, for example accented characters as well as normal character plus combining diacritic.

Right now I am trying to find out if ICU handles the codes 1-31 (possibly except 9, 10, 13) in CP 850. Will they be the graphical symbols or will they be ASCII control codes?

答:
By definition what you're talking about are control codes and are mapped as such by the Unicode specification to U+0001..U+001F (1..31). See the ICU Converter Explorer for example.

If you wanted the graphical representations instead, you'd need to find the graphical representations' Unicode equivalent and convert each code point yourself.

Title: Can ICU convert codes 1-31 in CP 850?


问:
How to add hover effect to TListBoxItem?
With other styles controls, I would normally add a background rectangle to a custom ListboxItem style and define a color animation with Trigger: IsMouseOver=true, but it does not work in this situation.

Only if I set HitTest := True for the background rectangle, then the hover animation works, but then the ListBox does not respond to clicks on the item, and you cannot select an item.

How do I add the hover effect to the ListBox?

答:
I ran into the same problem a while ago.
The only workaround i could find is to skip the style and create your own listboxitem. Only thing is your text will disappear, so i added a label to display the text.
Its not the great, but it worked in my case</p>

```<code>type
  TMouseOverListBoxItem = class(TListBoxItem)
  private
    FBackGround: TRectangle;
    FHoverAni: TColorAnimation;
    FLabel: TLabel;
    procedure BackgroundClicked(Sender: TObject);
  protected
    procedure DoTextChanged; override;
  public
    procedure AfterConstruction; override;
 end;

procedure TMouseOverListBoxItem.AfterConstruction;
const
  cStart = TAlphaColorRec.White;
  cStop  = TAlphaColorRec.Yellow;
begin
  inherited;
  // Create background
  FBackGround := TRectangle.Create(Self);
  FBackGround.Parent := Self;
  FBackGround.Fill.Color := cStart;
  FBackGround.Align := TAlignLayout.Contents;
  FBackGround.HitTest := True;
  FBackGround.Sides := [];
  FBackGround.OnClick := BackgroundClicked;

  // Create mouse over animation
  FHoverAni := TColorAnimation.Create(FBackGround);
  FHoverAni.Parent := FBackGround;
  FHoverAni.Trigger := 'IsMouseOver=true';
  FHoverAni.TriggerInverse := 'IsMouseOver=false';
  FHoverAni.StartValue := cStart;
  FHoverAni.StopValue := cStop;
  FHoverAni.PropertyName := 'Fill.Color';

   // Create label to show text. Background will hide original text
  FLabel := TLabel.Create(FBackGround);
  FLabel.Parent := FBackGround;
  FLabel.Align := TAlignLayout.Client;
end;

procedure TMouseOverListBoxItem.BackgroundClicked(Sender: TObject);
begin
  if Assigned(OnClick) then
    OnClick(Self)
  else if Assigned(ListBox.OnItemClick) then
    ListBox.OnItemClick(ListBox, Self);
end;

procedure TMouseOverListBoxItem.DoTextChanged;
begin
  inherited;
  FLabel.Text := Self.Text;
end;
</code>```

Body:
I ran into the same problem a while ago.
The only workaround i could find is to skip the style and create your own listboxitem. Only thing is your text will disappear, so i added a label to display the text.
Its not the great, but it worked in my case

type
  TMouseOverListBoxItem = class(TListBoxItem)
  private
    FBackGround: TRectangle;
    FHoverAni: TColorAnimation;
    FLabel: TLabel;
    procedure BackgroundClicked(Sender: TObject);
  protected
    procedure DoTextChanged; override;
  public
    procedure AfterConstruction; override;
 end;

procedure TMouseOverListBoxItem.AfterConstruction;
const
  cStart = TAlphaColorRec.White;
  cStop  = TAlphaColorRec.Yellow;
begin
  inherited;
  // Create background
  FBackGround := TRectangle.Create(Self);
  FBackGround.Parent := Self;
  FBackGround.Fill.Color := cStart;
  FBackGround.Align := TAlignLayout.Contents;
  FBackGround.HitTest := True;
  FBackGround.Sides := [];
  FBackGround.OnClick := BackgroundClicked;

  // Create mouse over animation
  FHoverAni := TColorAnimation.Create(FBackGround);
  FHoverAni.Parent := FBackGround;
  FHoverAni.Trigger := 'IsMouseOver=true';
  FHoverAni.TriggerInverse := 'IsMouseOver=false';
  FHoverAni.StartValue := cStart;
  FHoverAni.StopValue := cStop;
  FHoverAni.PropertyName := 'Fill.Color';

   // Create label to show text. Background will hide original text
  FLabel := TLabel.Create(FBackGround);
  FLabel.Parent := FBackGround;
  FLabel.Align := TAlignLayout.Client;
end;

procedure TMouseOverListBoxItem.BackgroundClicked(Sender: TObject);
begin
  if Assigned(OnClick) then
    OnClick(Self)
  else if Assigned(ListBox.OnItemClick) then
    ListBox.OnItemClick(ListBox, Self);
end;

procedure TMouseOverListBoxItem.DoTextChanged;
begin
  inherited;
  FLabel.Text := Self.Text;
end;


问:
Does safari/ios support autoplay of http live streams?
I'm a newbie to the whole HLS, M3U8 and autoplay. Does ios support autoplay of http live streaming with audio without any user gesture?

If so are there any sample webpages which I can load in safari on ios? I've used the examples in here https://bitmovin.com/mpeg-dash-hls-examples-sample-streams/ but none of them autoplay. What gives?

答:
Yes, this is trivial. Start with Apple's Deploying HTTP Live Streaming page.

This contains sample HTML for playing the "bip-bop" test stream. Save off that HTML to a file, and in the <video> tag, add autoplay="true". Open this file in Safari. Bang, autoplaying HLS.


问:
Easy way to write contents of a Java InputStream to an OutputStream
I was surprised to find today that I couldn't track down any simple way to write the contents of an InputStream to an OutputStream in Java. Obviously, the byte buffer code isn't difficult to write, but I suspect I'm just missing something which would make my life easier (and the code clearer).

So, given an InputStream in and an OutputStream out, is there a simpler way to write the following?

```<code>byte[] buffer = new byte[1024];
int len = in.read(buffer);
while (len != -1) {
    out.write(buffer, 0, len);
    len = in.read(buffer);
}
</code>```

答: PipedInputStream and PipedOutputStream may be of some use, as you can connect one to the other.</p>

OwnerDisplayName: Matt Sheppard

Body:
I was surprised to find today that I couldn't track down any simple way to write the contents of an InputStream to an OutputStream in Java. Obviously, the byte buffer code isn't difficult to write, but I suspect I'm just missing something which would make my life easier (and the code clearer).

So, given an InputStream in and an OutputStream out, is there a simpler way to write the following?

byte[] buffer = new byte[1024];
int len = in.read(buffer);
while (len != -1) {
    out.write(buffer, 0, len);
    len = in.read(buffer);
}

OwnerDisplayName: Trancecoder


问:
Nested control's events not firing in UserControl
Hello
I have a weird issue. I have a user control which I load dinamycally using LoadControl. In this UserControl I have a button whith assigned OnClick event, but when I click that button, the event is not fired.

```<code><%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ServiceInput.ascx.cs"
Inherits="uPay.UserControls.ServiceInputs.ServiceInput" ViewStateMode="Disabled" %>
    <div class="PopupFoot">
        <asp:Button ID="btnAdd" CssClass="PopupADD" runat="server" OnClick="btnAdd_Click" />
    </div>

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        //Method never gets called :/
    }
</code>```

Here I load user control in the page

```<code>protected void ServicesUpdatePanel_Load(object sender, EventArgs e)
{
        string arg = Request.Params.Get("__EVENTARGUMENT");
        if (arg == "ServiceInput")
        {
            int serviceId;
            if (Int32.TryParse(hdnSelectedService.Value, out serviceId))
            {
                using (Entities db = new Entities())
                {
                    LocalizedServiceRecord service = db.ServiceRecords.OfType<LocalizedServiceRecord>().FirstOrDefault(s => s.Id == serviceId && s.Language.Id == CurrentLanguage.Id);
                    lblPopupTitle.Text = service.Name;
                    ServiceInputBase serviceInput = LoadInputControl(service);
                    InputServicePlaceHolder.Controls.Add(serviceInput);
                    ServicesUpdatePanel.Update();
                }
            }
        }
}

    private ServiceInputBase LoadInputControl(ServiceRecord service)
    {
        ServiceInputBase serviceInput = LoadControl("~/UserControls/ServiceInputs/ServiceInput.ascx") as ServiceInputBase;

        return serviceInput;
    }
</code>```

Any Idea?

答:
Long time now, but maybe someone will find it useful. The problem was that when I clicked btnAdd, it caused a postback, and before it was able to trigger btnAdd_Click, the user control was already destroyed.

The solution to this problem is to recreate the usercontrol on postback.

Body:
Hello
I have a weird issue. I have a user control which I load dinamycally using LoadControl. In this UserControl I have a button whith assigned OnClick event, but when I click that button, the event is not fired.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ServiceInput.ascx.cs"
Inherits="uPay.UserControls.ServiceInputs.ServiceInput" ViewStateMode="Disabled" %>

        <asp:Button ID="btnAdd" CssClass="PopupADD" runat="server" OnClick="btnAdd_Click" />

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        //Method never gets called :/
    }

Here I load user control in the page

protected void ServicesUpdatePanel_Load(object sender, EventArgs e)
{
        string arg = Request.Params.Get("__EVENTARGUMENT");
        if (arg == "ServiceInput")
        {
            int serviceId;
            if (Int32.TryParse(hdnSelectedService.Value, out serviceId))
            {
                using (Entities db = new Entities())
                {
                    LocalizedServiceRecord service = db.ServiceRecords.OfType<LocalizedServiceRecord>().FirstOrDefault(s => s.Id == serviceId && s.Language.Id == CurrentLanguage.Id);
                    lblPopupTitle.Text = service.Name;
                    ServiceInputBase serviceInput = LoadInputControl(service);
                    InputServicePlaceHolder.Controls.Add(serviceInput);
                    ServicesUpdatePanel.Update();
                }
            }
        }
}

    private ServiceInputBase LoadInputControl(ServiceRecord service)
    {
        ServiceInputBase serviceInput = LoadControl("~/UserControls/ServiceInputs/ServiceInput.ascx") as ServiceInputBase;

        return serviceInput;
    }

Any Idea?


问:
pandas DataFrame error "tuple index out of range"
I have a problem backward filling a numpy date vector using the current version of pandas. The same code works with an earlier version. The following demonstrates my problem:

The older version (0.7.3) works

```<code>C:\WINDOWS\system32>pip show pandas
Name: pandas
Version: 0.7.3
Summary: Powerful data structures for data analysis and statistics
Home-page: http://pandas.pydata.org
Author: The PyData Development Team
Author-email: pydata@googlegroups.com
License: BSD
Location: c:\program files\python\python27\lib\site-packages
Requires: python-dateutil, numpy

C:\WINDOWS\system32>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> d=np.array([None, None, None, None, dt.now(), None])
>>> b = DataFrame(d)
>>> b.fillna(method='backfill')
                            0
0  2017-04-02 12:21:18.175000
1  2017-04-02 12:21:18.175000
2  2017-04-02 12:21:18.175000
3  2017-04-02 12:21:18.175000
4  2017-04-02 12:21:18.175000
5                        None
>>>
</code>```

The current vesion (0.19.2) doesn't work:

```<code>C:\WINDOWS\system32>pip show pandas
Name: pandas
Version: 0.19.2
Summary: Powerful data structures for data analysis, time series,and statistics
Home-page: http://pandas.pydata.org
Author: The PyData Development Team
Author-email: pydata@googlegroups.com
License: BSD
Location: c:\program files\python\python27\lib\site-packages
Requires: pytz, python-dateutil, numpy

C:\WINDOWS\system32>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime as dt
>>> import numpy as np
>>> from pandas import DataFrame
>>> d=np.array([None, None, None, None, dt.now(), None])
>>> b = DataFrame(d)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\frame.py", line 297, in __init__
    copy=copy)
  File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\frame.py", line 474, in _init_ndarray
    return create_block_manager_from_blocks([values], [columns, index])
  File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\internals.py", line 4256, in create_block_manager_from_blocks
    construction_error(tot_items, blocks[0].shape[1:], axes, e)
  File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\internals.py", line 4230, in construction_error
    if block_shape[0] == 0:
IndexError: tuple index out of range
>>>
</code>```

Am I doing something wrong or is it, as I think, a bug in pandas? If its a bug how do I report that?

EDIT: This was filed as a bug report with Pandas and will be fixed in the next minor relase (0.19.3)

答:
DataFrame(d) fails, and I'm not sure why, but Series(d) works, so you can do this:

```<code>pd.DataFrame({0:d})
</code>```

That is, explicitly tell Pandas that d is a Series called 0, which is what it was implicitly doing in the ancient 0.7 version.

If you do want to report a bug, you can simply say that this works:

```<code>pd.DataFrame([None, None, datetime.datetime.now()])
</code>```

But this fails:

```<code>pd.DataFrame([None, None, None, datetime.datetime.now()])
</code>```

Body:
I have a problem backward filling a numpy date vector using the current version of pandas. The same code works with an earlier version. The following demonstrates my problem:

The older version (0.7.3) works

C:\WINDOWS\system32>pip show pandas
Name: pandas
Version: 0.7.3
Summary: Powerful data structures for data analysis and statistics
Home-page: http://pandas.pydata.org
Author: The PyData Development Team
Author-email: pydata@googlegroups.com
License: BSD
Location: c:\program files\python\python27\lib\site-packages
Requires: python-dateutil, numpy

C:\WINDOWS\system32>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> d=np.array([None, None, None, None, dt.now(), None])
>>> b = DataFrame(d)
>>> b.fillna(method='backfill')
                            0
0  2017-04-02 12:21:18.175000
1  2017-04-02 12:21:18.175000
2  2017-04-02 12:21:18.175000
3  2017-04-02 12:21:18.175000
4  2017-04-02 12:21:18.175000
5                        None
>>>

The current vesion (0.19.2) doesn't work:

C:\WINDOWS\system32>pip show pandas
Name: pandas
Version: 0.19.2
Summary: Powerful data structures for data analysis, time series,and statistics
Home-page: http://pandas.pydata.org
Author: The PyData Development Team
Author-email: pydata@googlegroups.com
License: BSD
Location: c:\program files\python\python27\lib\site-packages
Requires: pytz, python-dateutil, numpy

C:\WINDOWS\system32>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime as dt
>>> import numpy as np
>>> from pandas import DataFrame
>>> d=np.array([None, None, None, None, dt.now(), None])
>>> b = DataFrame(d)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\frame.py", line 297, in __init__
    copy=copy)
  File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\frame.py", line 474, in _init_ndarray
    return create_block_manager_from_blocks([values], [columns, index])
  File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\internals.py", line 4256, in create_block_manager_from_blocks
    construction_error(tot_items, blocks[0].shape[1:], axes, e)
  File "C:\Program Files\Python\Python27\lib\site-packages\pandas\core\internals.py", line 4230, in construction_error
    if block_shape[0] == 0:
IndexError: tuple index out of range
>>>

Am I doing something wrong or is it, as I think, a bug in pandas? If its a bug how do I report that?

EDIT: This was filed as a bug report with Pandas and will be fixed in the next minor relase (0.19.3)

Body:
DataFrame(d) fails, and I'm not sure why, but Series(d) works, so you can do this:

pd.DataFrame({0:d})

That is, explicitly tell Pandas that d is a Series called 0, which is what it was implicitly doing in the ancient 0.7 version.

If you do want to report a bug, you can simply say that this works:

pd.DataFrame([None, None, datetime.datetime.now()])

But this fails:

pd.DataFrame([None, None, None, datetime.datetime.now()])