Here I am gonna enable sort on a field with double field, so in Entity Class, I code like
@Column(name = "price")
@Fields({
@Field(name = "listingPriceFrom", analyze = Analyze.NO, index = Index.YES)
})
@SortableField(forField = "listingPriceFrom")
private Double listingPriceFrom;
And this is a data lib worked as a artefact.
In ES engine, this field’s structure is like
"listingPriceFrom": {
"type": "double"
}
Then another service pulls this data lib in from NEXUS, after that, when spring boot starts the service, it shows the error message:
:18516:00:34.134 [restartedMain] DEBUG o.h.internal.SessionFactoryImpl [SessionFactoryImpl.java:741]- HHH000031: Closing
:74116:00:34.136 [restartedMain] DEBUG o.h.internal.SessionFactoryRegistry [SessionFactoryRegistry.java:52]- Initializing SessionFactoryRegistry : org.hibernate.internal.SessionFactoryRegistry@646e8d3d
:5216:00:34.137 [restartedMain] DEBUG o.hibernate.engine.spi.CascadeStyles [CascadeStyles.java:268]- External cascade style registration [persist : STYLE_PERSIST] overrode base registration [STYLE_PERSIST_SKIPLAZY]
:26816:00:34.137 [restartedMain] DEBUG o.h.s.i.AbstractServiceRegistryImpl [AbstractServiceRegistryImpl.java:414]- Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries
:41416:00:34.137 [restartedMain] DEBUG o.h.b.r.i.BootstrapServiceRegistryImpl [BootstrapServiceRegistryImpl.java:295]- Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries
:29516:00:34.137 [restartedMain] DEBUG o.hibernate.engine.spi.CascadeStyles [CascadeStyles.java:268]- External cascade style registration [persist : STYLE_PERSIST] overrode base registration [STYLE_PERSIST]
:26816:00:34.138 [restartedMain] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext [Jdk14Logger.java:87]- Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.NullPointerException
:8716:00:34.138 [restartedMain] INFO com.zaxxer.hikari.HikariDataSource [HikariDataSource.java:381]- HikariPool-1 - Shutdown initiated...
:38116:00:34.139 [restartedMain] DEBUG com.zaxxer.hikari.pool.HikariPool [HikariPool.java:404]- HikariPool-1 - Before shutdown stats (total=1, active=0, idle=1, waiting=0)
:40416:00:34.139 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase [PoolBase.java:127]- HikariPool-1 - Closing connection com.mysql.cj.jdbc.ConnectionImpl@3ba2fa0d: (connection evicted)
:12716:00:34.141 [restartedMain] DEBUG com.zaxxer.hikari.pool.HikariPool [HikariPool.java:404]- HikariPool-1 - After shutdown stats (total=0, active=0, idle=0, waiting=0)
:40416:00:34.141 [restartedMain] INFO com.zaxxer.hikari.HikariDataSource [HikariDataSource.java:383]- HikariPool-1 - Shutdown completed.
:38316:00:34.144 [restartedMain] INFO o.a.catalina.core.StandardService [DirectJDKLog.java:180]- Stopping service [Tomcat]
No idea why, but I am sure it only deals with this Double
field, if we remove Fields
line and SortableField
in entity class, pull that in, service could start as normal as expected.
By the way, I’ve tried adding a field, like
@FieldBridge(impl = DoubleBridge.class)
but it seems wrong actually cuz it turns out to be a sorting based on the string instead of a number, right?
The searching class is like:
Anyone can help?