Solr could not get value for property on Broadleaf Commerce - solr

I am trying to install Broadleaf Commerce Community Edition (6.1.3-GA) on macOS.
I have successfully installed Solr 8.6.0 locally and get this response at http://localhost:8983/solr/admin/cores?action=STATUS
{
"responseHeader":{
"status":0,
"QTime":47},
"initFailures":{},
"status":{
"catalog":{
"name":"catalog",
"instanceDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/catalog",
"dataDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/catalog/data/",
"config":"solrconfig.xml",
"schema":"managed-schema",
"startTime":"2020-08-04T03:13:32.320Z",
"uptime":126010809,
"index":{
"numDocs":0,
"maxDoc":0,
"deletedDocs":0,
"indexHeapUsageBytes":0,
"version":2,
"segmentCount":0,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.MMapDirectory:MMapDirectory#/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/catalog/data/index lockFactory=org.apache.lucene.store.NativeFSLockFactory#5fb1ae26",
"segmentsFile":"segments_1",
"segmentsFileSizeInBytes":69,
"userData":{},
"sizeInBytes":69,
"size":"69 bytes"}},
"catalog_reindex":{
"name":"catalog_reindex",
"instanceDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/catalog_reindex",
"dataDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/catalog_reindex/data/",
"config":"solrconfig.xml",
"schema":"managed-schema",
"startTime":"2020-08-04T03:13:32.988Z",
"uptime":126010160,
"index":{
"numDocs":0,
"maxDoc":0,
"deletedDocs":0,
"indexHeapUsageBytes":0,
"version":2,
"segmentCount":0,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.MMapDirectory:MMapDirectory#/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/catalog_reindex/data/index lockFactory=org.apache.lucene.store.NativeFSLockFactory#5fb1ae26",
"segmentsFile":"segments_1",
"segmentsFileSizeInBytes":69,
"userData":{},
"sizeInBytes":69,
"size":"69 bytes"}},
"customers":{
"name":"customers",
"instanceDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/customers",
"dataDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/customers/data/",
"config":"solrconfig.xml",
"schema":"managed-schema",
"startTime":"2020-08-04T03:13:32.209Z",
"uptime":126010941,
"index":{
"numDocs":0,
"maxDoc":0,
"deletedDocs":0,
"indexHeapUsageBytes":0,
"version":2,
"segmentCount":0,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.MMapDirectory:MMapDirectory#/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/customers/data/index lockFactory=org.apache.lucene.store.NativeFSLockFactory#5fb1ae26",
"segmentsFile":"segments_1",
"segmentsFileSizeInBytes":69,
"userData":{},
"sizeInBytes":69,
"size":"69 bytes"}},
"customers_reindex":{
"name":"customers_reindex",
"instanceDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/customers_reindex",
"dataDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/customers_reindex/data/",
"config":"solrconfig.xml",
"schema":"managed-schema",
"startTime":"2020-08-04T03:13:32.935Z",
"uptime":126010216,
"index":{
"numDocs":0,
"maxDoc":0,
"deletedDocs":0,
"indexHeapUsageBytes":0,
"version":2,
"segmentCount":0,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.MMapDirectory:MMapDirectory#/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/customers_reindex/data/index lockFactory=org.apache.lucene.store.NativeFSLockFactory#5fb1ae26",
"segmentsFile":"segments_1",
"segmentsFileSizeInBytes":69,
"userData":{},
"sizeInBytes":69,
"size":"69 bytes"}},
"fulfillment_orders":{
"name":"fulfillment_orders",
"instanceDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/fulfillment_orders",
"dataDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/fulfillment_orders/data/",
"config":"solrconfig.xml",
"schema":"managed-schema",
"startTime":"2020-08-04T03:13:32.209Z",
"uptime":126010942,
"index":{
"numDocs":0,
"maxDoc":0,
"deletedDocs":0,
"indexHeapUsageBytes":0,
"version":2,
"segmentCount":0,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.MMapDirectory:MMapDirectory#/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/fulfillment_orders/data/index lockFactory=org.apache.lucene.store.NativeFSLockFactory#5fb1ae26",
"segmentsFile":"segments_1",
"segmentsFileSizeInBytes":69,
"userData":{},
"sizeInBytes":69,
"size":"69 bytes"}},
"fulfillment_orders_reindex":{
"name":"fulfillment_orders_reindex",
"instanceDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/fulfillment_orders_reindex",
"dataDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/fulfillment_orders_reindex/data/",
"config":"solrconfig.xml",
"schema":"managed-schema",
"startTime":"2020-08-04T03:13:32.934Z",
"uptime":126010220,
"index":{
"numDocs":0,
"maxDoc":0,
"deletedDocs":0,
"indexHeapUsageBytes":0,
"version":2,
"segmentCount":0,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.MMapDirectory:MMapDirectory#/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/fulfillment_orders_reindex/data/index lockFactory=org.apache.lucene.store.NativeFSLockFactory#5fb1ae26",
"segmentsFile":"segments_1",
"segmentsFileSizeInBytes":69,
"userData":{},
"sizeInBytes":69,
"size":"69 bytes"}},
"orders":{
"name":"orders",
"instanceDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/orders",
"dataDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/orders/data/",
"config":"solrconfig.xml",
"schema":"managed-schema",
"startTime":"2020-08-04T03:13:33.091Z",
"uptime":126010063,
"index":{
"numDocs":0,
"maxDoc":0,
"deletedDocs":0,
"indexHeapUsageBytes":0,
"version":2,
"segmentCount":0,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.MMapDirectory:MMapDirectory#/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/orders/data/index lockFactory=org.apache.lucene.store.NativeFSLockFactory#5fb1ae26",
"segmentsFile":"segments_1",
"segmentsFileSizeInBytes":69,
"userData":{},
"sizeInBytes":69,
"size":"69 bytes"}},
"orders_reindex":{
"name":"orders_reindex",
"instanceDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/orders_reindex",
"dataDir":"/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/orders_reindex/data/",
"config":"solrconfig.xml",
"schema":"schema.xml",
"startTime":"2020-08-04T03:13:33.110Z",
"uptime":126010045,
"index":{
"numDocs":0,
"maxDoc":0,
"deletedDocs":0,
"indexHeapUsageBytes":0,
"version":2,
"segmentCount":0,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.MMapDirectory:MMapDirectory#/Users/gunther/Desktop/solr-8.6.0/server/solr/solrhome/cores/orders_reindex/data/index lockFactory=org.apache.lucene.store.NativeFSLockFactory#5fb1ae26",
"segmentsFile":"segments_1",
"segmentsFileSizeInBytes":69,
"userData":{},
"sizeInBytes":69,
"size":"69 bytes"}}}}
As you can see Solr seems to be working but i get this error while compiling Broadleaf Commerce:
ERROR 47828 --- [ main] o.b.c.s.s.s.index.SolrIndexServiceImpl : Could not get value for property[Product.productAttributes(heatRange).value] for product id[2]
java.lang.reflect.InvocationTargetException: null
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:2116) ~[commons-beanutils-1.9.2.jar:1.9.2]
at org.apache.commons.beanutils.PropertyUtilsBean.getMappedProperty(PropertyUtilsBean.java:690) ~[commons-beanutils-1.9.2.jar:1.9.2]
at org.apache.commons.beanutils.PropertyUtilsBean.getMappedProperty(PropertyUtilsBean.java:614) ~[commons-beanutils-1.9.2.jar:1.9.2]
at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:804) ~[commons-beanutils-1.9.2.jar:1.9.2]
at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:884) ~[commons-beanutils-1.9.2.jar:1.9.2]
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:464) ~[commons-beanutils-1.9.2.jar:1.9.2]
at org.broadleafcommerce.core.search.service.solr.SolrHelperServiceImpl.getPropertyValueInternal(SolrHelperServiceImpl.java:952) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.SolrHelperServiceImpl.getPropertyValue(SolrHelperServiceImpl.java:430) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.SolrHelperServiceImpl.getPropertyValue(SolrHelperServiceImpl.java:424) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.index.SolrIndexServiceImpl.getPropertyValues(SolrIndexServiceImpl.java:677) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.index.SolrIndexServiceImpl.attachIndexableDocumentFields(SolrIndexServiceImpl.java:526) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.index.SolrIndexServiceImpl.buildDocument(SolrIndexServiceImpl.java:506) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.index.SolrIndexServiceImpl.buildIncrementalIndex(SolrIndexServiceImpl.java:436) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.index.SolrIndexServiceImpl$1.buildPage(SolrIndexServiceImpl.java:229) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.index.SolrIndexServiceImpl.buildIncrementalIndex(SolrIndexServiceImpl.java:386) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.index.SolrIndexServiceImpl$2.execute(SolrIndexServiceImpl.java:269) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.index.SolrIndexServiceImpl.performCachedOperation(SolrIndexServiceImpl.java:173) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.index.SolrIndexServiceImpl.executeSolrIndexOperation(SolrIndexServiceImpl.java:256) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.index.SolrIndexServiceImpl.buildIndex(SolrIndexServiceImpl.java:198) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.search.service.solr.index.SolrIndexServiceImpl.rebuildIndex(SolrIndexServiceImpl.java:185) ~[broadleaf-framework-6.1.3-GA.jar:na]
at com.community.core.service.search.SolrIndexCleanupServiceImpl.rebuildIndexAtStartupIfNecessary(SolrIndexCleanupServiceImpl.java:54) ~[boot-community-demo-core-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at com.community.core.service.search.SolrIndexCleanupServiceImpl$$FastClassBySpringCGLIB$$b84b8451.invoke(<generated>) ~[boot-community-demo-core-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:752) ~[spring-aop-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295) ~[spring-tx-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) ~[spring-tx-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) ~[spring-aop-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at com.community.core.service.search.SolrIndexCleanupServiceImpl$$EnhancerBySpringCGLIB$$1576716f.rebuildIndexAtStartupIfNecessary(<generated>) ~[boot-community-demo-core-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:261) ~[spring-context-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:179) ~[spring-context-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:142) ~[spring-context-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) ~[spring-context-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) ~[spring-context-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:897) ~[spring-context-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-2.1.15.RELEASE.jar:2.1.15.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) ~[spring-context-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.15.RELEASE.jar:2.1.15.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) ~[spring-boot-2.1.15.RELEASE.jar:2.1.15.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) ~[spring-boot-2.1.15.RELEASE.jar:2.1.15.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.1.15.RELEASE.jar:2.1.15.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.1.15.RELEASE.jar:2.1.15.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) ~[spring-boot-2.1.15.RELEASE.jar:2.1.15.RELEASE]
at com.community.admin.AdminApplication.main(AdminApplication.java:18) ~[classes/:na]
Caused by: java.lang.IllegalArgumentException: A locale could not be found for the provided localeCode: en_DE
at org.broadleafcommerce.common.i18n.service.TranslationServiceImpl.shouldTranslateLocale(TranslationServiceImpl.java:236) ~[broadleaf-common-6.1.3-GA.jar:na]
at org.broadleafcommerce.common.i18n.service.TranslationServiceImpl.getTranslatedValue(TranslationServiceImpl.java:189) ~[broadleaf-common-6.1.3-GA.jar:na]
at org.broadleafcommerce.common.i18n.service.TranslationServiceImpl$$FastClassBySpringCGLIB$$f73424a7.invoke(<generated>) ~[broadleaf-common-6.1.3-GA.jar:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687) ~[spring-aop-5.1.16.RELEASE.jar:5.1.16.RELEASE]
at org.broadleafcommerce.common.i18n.service.TranslationServiceImpl$$EnhancerBySpringCGLIB$$2ed43831.getTranslatedValue(<generated>) ~[broadleaf-common-6.1.3-GA.jar:na]
at org.broadleafcommerce.common.i18n.service.DynamicTranslationProvider.getValue(DynamicTranslationProvider.java:48) ~[broadleaf-common-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.catalog.domain.ProductAttributeImpl.getName(ProductAttributeImpl.java:116) ~[broadleaf-framework-6.1.3-GA.jar:na]
at org.broadleafcommerce.core.catalog.domain.ProductImpl.getProductAttributes(ProductImpl.java:921) ~[broadleaf-framework-6.1.3-GA.jar:na]
... 56 common frames omitted
Here is the relevant content from solr-8.6.0/server/logs
2020-08-05 17:18:43.914 INFO (qtp2138005960-24) [ x:catalog_reindex] o.a.s.u.p.LogUpdateProcessorFactory [catalog_reindex] webapp=/solr path=/update params={wt=javabin&version=2}{deleteByQuery=namespace:("d") (-1674206693462900736)} 0 3
2020-08-05 17:18:43.937 INFO (qtp2138005960-21) [ x:catalog_reindex] o.a.s.u.p.LogUpdateProcessorFactory [catalog_reindex] webapp=/solr path=/update params={waitSearcher=true&commit=true&softCommit=false&wt=javabin&version=2}{commit=} 0 2
I have read question 53358713, I do not think it is the same. Thank you very much!

Try entering en_DE into BLC_LOCALE
INSERT INTO BLC_LOCALE (LOCALE_CODE, DEFAULT_FLAG, FRIENDLY_NAME, CURRENCY_CODE) VALUES ('en_DE', FALSE, 'English (Germany)', 'EUR');

Related

Generate Sequence Code A-Z then 0-9 on SQL Server

I have a case to generate sequence ID but alphabet first then numeric ( A-Z then 0-9 ) I see the question
here and try the solution, but the solution always give me 0-9 first then A-Z
WITH seq AS
(
SELECT
ROW_NUMBER() OVER (ORDER BY x.alpha + y.number + z.number ) AS Id,
CONVERT(nchar(3), x.alpha + y.number + z.number) AS Result
FROM
(
VALUES
('0'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9'),
('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),
('K'), ('L'), ('M'), ('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),
('U'), ('V'), ('W'), ('X'), ('Y'), ('Z')
) x(alpha) ,
(
VALUES
('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),
('K'), ('L'), ('M'), ('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),
('U'), ('V'), ('W'), ('X'), ('Y'), ('Z'),
('0'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9')
) y(number),
(
VALUES
('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),
('K'), ('L'), ('M'), ('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),
('U'), ('V'), ('W'), ('X'), ('Y'), ('Z'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9')
) z(number)
)
SELECT * FROM seq WHERE Id = (SELECT Id + 1 FROM seq WHERE Result = 'A1Z')
the Sequence what should generated is :
AAA,...,AAZ,AA1,...,AA9,ABA,...,ABZ,AB1,..,AB9,...999
sample when I hit the A1Z the expected next value is A11, but the solution I tried give me A21 , is the behavior of SQL is start by 0-9 then A-Z , how to accomplish my requirement ?
Perhaps this is what you want? Numbers have lower value than letters in T-SQL, so when you order them then '9' has a lower number than 'A'. What you could do, however, is check if the value is a valid int value or not, and then order the values that aren't first, and then by the character.
This gives you the following:
WITH Characters AS(
SELECT V.C
FROM (VALUES('0'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9'),
('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),
('K'), ('L'), ('M'), ('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),
('U'), ('V'), ('W'), ('X'), ('Y'), ('Z')) V(C)),
Sequences AS(
SELECT CONCAT(C1.C,C2.C,C3.C) AS Sequence,
ROW_NUMBER() OVER (ORDER BY TRY_CONVERT(int,C1.C), C1.C, TRY_CONVERT(int,C2.C), C2.C, TRY_CONVERT(int,C3.C), C3.C) AS RN
FROM Characters C1
CROSS JOIN Characters C2
CROSS JOIN Characters C3)
SELECT *
FROM Sequences;
You didn't state where 0 goes, so I assumed 'AAZ','AA0', 'AA1'...
You can try to use ASCII function with a simple algorithm in ORDER BY, judging the char whether number or letter. if the char is number need to add 43
because the gap between Z (Capital letter) and 0 (first number) is 43, we need to add 43 to the number char to make sure the number is always behind letters.
WITH seq AS
(
SELECT
ROW_NUMBER() OVER (ORDER BY IIF(x.alpha LIKE '[A-Z]', ASCII(x.alpha), ASCII(x.alpha) + 43),
IIF(y.number LIKE '[A-Z]', ASCII(y.number), ASCII(y.number) + 43),
IIF(z.number LIKE '[A-Z]', ASCII(z.number), ASCII(z.number) + 43)) AS Id,
CONVERT(nchar(3), x.alpha + y.number + z.number) AS Result
FROM
(
VALUES
('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),
('K'), ('L'), ('M'), ('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),
('U'), ('V'), ('W'), ('X'), ('Y'), ('Z'),
('0'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9')
) x(alpha) ,
(
VALUES
('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),
('K'), ('L'), ('M'), ('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),
('U'), ('V'), ('W'), ('X'), ('Y'), ('Z'),
('0'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9')
) y(number),
(
VALUES
('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),
('K'), ('L'), ('M'), ('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),
('U'), ('V'), ('W'), ('X'), ('Y'), ('Z'),
('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9')
) z(number)
)
SELECT * FROM seq WHERE Id = (SELECT Id + 1 FROM seq WHERE Result = 'A1Z');
sqlfiddle

Calculating the Count of every pair product for every Order Divided by the number of every product and insert the result in correlation table

Hello Every one I have a historical data-set of sales and i want to create a query which calculate the correlation between the products by calculating the number of orders which has every pair products and then dividing this number over the number of all orders which Has one of this pair, As Ex ( If i want to calculate the correlation between Product "A" and Product "B" then i will count all orders which has "A" & "B" in the same order and then dividing this count over the orders which has Product "A" only [this will differ if i want to get the correlation between "B" & "A"]).
and i want to store this result in a table of correlation As Shown in the Flowing image
and this is a sample of 300 Row from my data
structure(list(ï..OrderId = c(137413L, 137413L, 137413L, 137413L,
137413L, 137413L, 137413L, 137413L, 137413L, 137413L, 137413L,
137413L, 136729L, 136729L, 136729L, 136729L, 136729L, 136729L,
136729L, 136729L, 136729L, 136729L, 136729L, 136729L, 136729L,
137260L, 137260L, 137260L, 137260L, 137260L, 137260L, 137260L,
137260L, 137260L, 137260L, 137429L, 137429L, 137429L, 137429L,
137429L, 137429L, 137429L, 137429L, 137429L, 137902L, 137902L,
137902L, 137902L, 137902L, 137902L, 137902L, 137974L, 137974L,
138837L, 138837L, 138837L, 138837L, 138837L, 138837L, 139424L,
139424L, 139424L, 139424L, 139424L, 139424L, 139424L, 139424L,
139424L, 139642L, 139642L, 139642L, 139642L, 139642L, 139642L,
139642L, 140676L, 140676L, 140676L, 140676L, 140676L, 140676L,
140938L, 140938L, 140938L, 140938L, 140938L, 140938L, 140938L,
140938L, 140938L, 140938L, 141302L, 141302L, 141302L, 141302L,
141302L, 141302L, 137302L, 137302L, 137302L, 137302L, 138297L,
138297L, 138297L, 138297L, 138297L, 138297L, 138297L, 138297L,
138297L, 138297L, 138297L, 138297L, 138297L, 134444L, 134444L,
134444L, 141134L, 141134L, 141134L, 141134L, 134468L, 134468L,
131965L, 131965L, 131965L, 131965L, 131965L, 131965L, 131965L,
131965L, 131965L, 135722L, 135722L, 135722L, 135722L, 135722L,
135722L, 135722L, 135722L, 135722L, 135722L, 135722L, 135722L,
135722L, 135722L, 139444L, 139444L, 139444L, 139444L, 139444L,
139444L, 131866L, 131866L, 131866L, 131866L, 131866L, 131866L,
131866L, 136078L, 136078L, 136078L, 136078L, 136078L, 136078L,
136078L, 136078L, 136078L, 136078L, 136078L, 136078L, 136078L,
137419L, 137419L, 137419L, 137419L, 137419L, 137419L, 137419L,
137419L, 137419L, 137419L, 137419L, 137419L, 139214L, 139214L,
139214L, 139214L, 139214L, 139214L, 131997L, 131997L, 131997L,
131997L, 139482L, 139482L, 139482L, 139482L, 139482L, 139482L,
139482L, 136066L, 136066L, 136066L, 136066L, 136066L, 136066L,
136066L, 136610L, 136610L, 136610L, 136610L, 136610L, 137352L,
137352L, 137352L, 137352L, 137352L, 137352L, 137352L, 137352L,
133358L, 133358L, 133358L, 134522L, 134522L, 134522L, 134522L,
134522L, 134522L, 134522L, 134522L, 131481L, 131481L, 131481L,
131918L, 131918L, 131918L, 131918L, 135758L, 135758L, 135758L,
135758L, 135678L, 135678L, 135678L, 135678L, 135678L, 135678L,
135678L, 135678L, 135678L, 131986L, 131986L, 131986L, 131986L,
131986L, 131986L, 131986L, 139468L, 139468L, 139468L, 139468L,
139468L, 139468L, 139468L, 139468L, 139468L, 139468L, 139533L,
139533L, 139533L, 139533L, 139533L, 139533L, 139533L, 139533L,
139533L, 131950L, 137540L, 137540L, 137540L, 137540L, 137540L,
137540L, 137540L, 138021L, 138021L, 138021L, 138021L, 138021L,
138021L, 138021L, 138021L, 138021L, 134490L, 134490L, 134490L,
134490L, 134490L), Items = structure(c(29L, 27L, 79L, 35L, 50L,
77L, 32L, 80L, 24L, 60L, 20L, 44L, 46L, 47L, 27L, 68L, 14L, 35L,
22L, 77L, 15L, 73L, 80L, 60L, 42L, 29L, 27L, 68L, 51L, 10L, 35L,
22L, 73L, 62L, 60L, 27L, 51L, 10L, 37L, 35L, 22L, 62L, 80L, 60L,
47L, 68L, 51L, 10L, 22L, 77L, 73L, 51L, 10L, 18L, 47L, 73L, 24L,
60L, 20L, 18L, 29L, 47L, 17L, 35L, 77L, 11L, 73L, 78L, 46L, 18L,
29L, 9L, 17L, 35L, 73L, 46L, 18L, 9L, 17L, 35L, 73L, 18L, 29L,
27L, 22L, 50L, 19L, 73L, 13L, 1L, 7L, 46L, 8L, 80L, 24L, 60L,
61L, 48L, 64L, 10L, 6L, 29L, 47L, 27L, 28L, 10L, 22L, 15L, 73L,
62L, 24L, 60L, 20L, 58L, 66L, 67L, 43L, 38L, 36L, 74L, 70L, 74L,
37L, 74L, 37L, 22L, 77L, 34L, 15L, 73L, 62L, 67L, 46L, 53L, 63L,
57L, 74L, 48L, 27L, 17L, 14L, 15L, 73L, 12L, 67L, 43L, 18L, 29L,
14L, 35L, 32L, 73L, 46L, 18L, 52L, 19L, 62L, 71L, 23L, 14L, 35L,
34L, 19L, 73L, 13L, 43L, 39L, 24L, 75L, 20L, 3L, 41L, 29L, 27L,
68L, 64L, 14L, 35L, 11L, 19L, 15L, 73L, 43L, 45L, 65L, 55L, 67L,
61L, 58L, 40L, 57L, 74L, 31L, 73L, 69L, 65L, 30L, 73L, 56L, 49L,
61L, 74L, 19L, 72L, 13L, 43L, 26L, 41L, 46L, 27L, 68L, 60L, 41L,
74L, 27L, 37L, 14L, 73L, 43L, 60L, 41L, 74L, 32L, 67L, 4L, 29L,
59L, 21L, 25L, 76L, 73L, 43L, 57L, 74L, 62L, 74L, 54L, 33L, 2L,
15L, 73L, 62L, 80L, 59L, 21L, 25L, 27L, 14L, 15L, 73L, 43L, 80L,
57L, 31L, 32L, 19L, 15L, 73L, 72L, 46L, 16L, 18L, 29L, 5L, 14L,
35L, 22L, 73L, 61L, 46L, 18L, 29L, 5L, 14L, 35L, 22L, 73L, 61L,
74L, 46L, 18L, 29L, 27L, 73L, 62L, 43L, 68L, 65L, 64L, 10L, 37L,
17L, 11L, 61L, 70L, 59L, 21L, 25L, 76L, 14L), .Label = c(" Green Beans",
"Apricot", "Arugula", "Arugula old", "Autumn Royal Grape", "Avocado",
"Baladi Cabbage", "Baladi Garlic", "Banati Grape", "Barshomi Figs",
"Black Eggplant", "Broccoli", "Cantaloupe", "Capsicum", "Carrot",
"Cauliflower", "Chili Pepper", "Classic Eggplant", "Cooking Potato",
"Coriander", "Coriander old", "Cucumber", "Deluxe Dried Dates",
"Dill", "Dill old", "Dried Dates", "Flame Grape", "Fons Mango",
"frying Potato", "Gala Apple", "Golden Apple", "Golden Onion",
"Granny Apple", "Grape Leaves", "Green pepper", "Guava", "Hot Pepper",
"Imported Peach", "Japanese Plum", "Lebanese Apple", "Local Apple",
"Local Celery ", "Local Cucumber", "Local Eggplant", "Local Hot Pepper",
"Local Lemon", "Local Pear", "Melon", "Mint", "Molokhia", "Momtaza Owais Mango",
"Morket Tangerine", "Mushroom (200G) old", "Nectarine Peach",
"Nems Watermelon (KG)", "Okra", "Orange For Juice", "Owais Mango",
"Parsle old", "Parsley", "Red Globe Grape", "Red Onion", "Red Radish old",
"Sadeeka Mango", "Sokkary Mango", "Strawberry", "Sugary Peach",
"Superior Grape", "Sweet Potato", "Syrian plum", "Tamr hendi",
"Taro", "Tomato", "Watermelon ( per KG)", "White Cabbage", "White Cabbage Old",
"White Eggplant ", "Zaghlol Dates", "Zebdaya Mango", "Zucchini"
), class = "factor")), .Names = c("ï..OrderId", "Items"), class = "data.frame", row.names = c(NA,
-300L))
Calculate the total orders for each product
Pair each product with every one else
Join the pair with orders to find which orders have both products
join all together to have COUNT(A&B) and COUNT(A)
SQL DEMO
WITH products as (
SELECT [OtherLangDescription], COUNT(*) as orders_total
FROM Orders
GROUP BY [OtherLangDescription]
), correlation as (
SELECT p1.[OtherLangDescription] as p1,
p1.orders_total as total1,
p2.[OtherLangDescription] as p2,
p2.orders_total as total2
FROM products p1
CROSS JOIN products p2
), dual_products as (
SELECT p1, p2, COUNT (o1.OrderID) as pair_orders_total
FROM correlation c
JOIN orders o1
ON c.p1 = o1.[OtherLangDescription]
JOIN orders o2
ON c.p2 = o2.[OtherLangDescription]
AND o1.orderID = o2.orderID
GROUP BY p1, p2
)
SELECT c.*,
d.pair_orders_total,
d.pair_orders_total * 1.0 / c.total1 as correlation
FROM correlation c
JOIN dual_products d
ON c.p1 = d.p1
AND c.p2 = d.p2
If you save the previous result as table Result the pivot is like this:
SQL DEMO
DECLARE #cols AS NVARCHAR(MAX),
#query AS NVARCHAR(MAX);
SET #cols = STUFF((SELECT ',' + QUOTENAME(p2)
FROM Results c
GROUP BY p2
ORDER BY p2
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'')
set #query = 'SELECT p1, ' + #cols + ' from
(
select p1
, p2
, correlation
from Results
) x
pivot
(
max(correlation)
for p2 in (' + #cols + ')
) p
ORDER BY p1'
execute(#query);
OUTPUT

Springboot application - Unable to create initial connections of pool (SQL Server)

Everything was working fine until just a few days ago. I have not modified any code since last running the application successfully. What could have possibly caused my connection to the database to start failing? I have made sure to test in the SSMS Object Explorer and can connect to the database as an SQL user with the user/pass shown below:
My application.properties file:
# MsSQL Connection
spring.datasource.url=jdbc:sqlserver://host:port;database=springbootdb;
spring.datasource.username=TMTAdmin
spring.datasource.password=pass123!
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto=create-drop
2017-03-14 10:19:53.406 ERROR 108236 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
Exception
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'TMTAdmin'. ClientConnectionId:0f665431-7f24-49a7-b900-e966db1eb14a
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:279) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:99) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4346) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3160) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:43) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3123) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7505) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2445) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1981) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1628) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1459) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:773) ~[sqljdbc4-4.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1168) ~[sqljdbc4-4.0.jar:na]
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310) ~[tomcat-jdbc-8.5.11.jar:na]
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.11.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:732) [tomcat-jdbc-8.5.11.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:664) [tomcat-jdbc-8.5.11.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:479) [tomcat-jdbc-8.5.11.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154) [tomcat-jdbc-8.5.11.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) [tomcat-jdbc-8.5.11.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) [tomcat-jdbc-8.5.11.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131) [tomcat-jdbc-8.5.11.jar:na]
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) [spring-jdbc-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) [spring-jdbc-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:316) [spring-jdbc-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:356) [spring-jdbc-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.autoconfigure.orm.jpa.DatabaseLookup.getDatabase(DatabaseLookup.java:72) [spring-boot-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.determineDatabase(JpaProperties.java:139) [spring-boot-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter(JpaBaseConfiguration.java:106) [spring-boot-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$3b9a2ba.CGLIB$jpaVendorAdapter$9(<generated>) [spring-boot-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$3b9a2ba$$FastClassBySpringCGLIB$$fab0077c.invoke(<generated>) [spring-boot-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) [spring-core-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) [spring-context-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$3b9a2ba.jpaVendorAdapter(<generated>) [spring-boot-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1193) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1087) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:484) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:250) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1128) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1056) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:833) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:740) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:466) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1193) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1087) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:484) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:250) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1128) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1056) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:833) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:740) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:466) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1193) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1087) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:484) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1079) [spring-context-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:855) [spring-context-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) [spring-context-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:809) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:404) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:347) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1249) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at com.martin.TmtApplication.main(TmtApplication.java:12) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:527) [spring-boot-maven-plugin-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
What's going on?

Async redirect in Grails 3.0

Async redirect in grails 3.0 controller fails.
Below is sample controller snippet;
import static grails.async.Promises.*
class WaitController {
def index() {
if (request.asyncContext) {
render 'index sync'
} else {
task {
render 'index async'
}
}
}
def redirectSync() {
redirect action:'index'
// works very well
}
def redirectAsync() {
task {
try {
redirect action:'index'
} catch (Exception ex) {
log.error('async redirect', ex)
}
}
}
}
The exception's stack trace is like;
ERROR grails.app.controllers.grails3.event.driven.WaitController - async redirect
org.hibernate.HibernateException: No Session found for current thread
at org.grails.orm.hibernate.GrailsSessionContext.currentSession(GrailsSessionContext.java:117) ~[grails-datastore-gorm-hibernate4-4.0.6.RELEASE.jar:na]
at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.grails.orm.hibernate.SessionFactoryProxy.getCurrentSession(SessionFactoryProxy.java:148) ~[grails-datastore-gorm-hibernate4-4.0.6.RELEASE.jar:na]
at org.grails.orm.hibernate.support.FlushOnRedirectEventListener.responseRedirected(FlushOnRedirectEventListener.java:38) ~[grails-datastore-gorm-hibernate4-4.0.6.RELEASE.jar:na]
at grails.web.mapping.ResponseRedirector.redirectResponse(ResponseRedirector.groovy:101) ~[grails-web-url-mappings-3.0.8.jar:3.0.8]
at grails.web.mapping.ResponseRedirector.redirect(ResponseRedirector.groovy:79) ~[grails-web-url-mappings-3.0.8.jar:3.0.8]
at grails.artefact.controller.support.ResponseRedirector$Trait$Helper.redirect(ResponseRedirector.groovy:119) ~[grails-plugin-controllers-3.0.8.jar:3.0.8]
at sun.reflect.GeneratedMethodAccessor366.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:201510201305]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214) [groovy-2.4.4.jar:2.4.4]
at grails3.event.driven.WaitController.grails_artefact_Controllertrait$super$redirect(WaitController.groovy) ~[main/:na]
at sun.reflect.GeneratedMethodAccessor380.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:201510201305]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) [groovy-2.4.4.jar:2.4.4]
at grails.artefact.Controller$Trait$Helper.redirect(Controller.groovy:241) ~[grails-plugin-controllers-3.0.8.jar:3.0.8]
at sun.reflect.GeneratedMethodAccessor365.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:201510201305]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:91) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) [groovy-2.4.4.jar:2.4.4]
at grails3.event.driven.WaitController.redirect(WaitController.groovy) ~[main/:na]
at sun.reflect.GeneratedMethodAccessor364.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:201510201305]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) ~[groovy-2.4.4.jar:2.4.4]
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384) ~[groovy-2.4.4.jar:2.4.4]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69) [groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) [groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) [groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) [groovy-2.4.4.jar:2.4.4]
at grails3.event.driven.WaitController$_redirectAsync_closure2.doCall(WaitController.groovy:21) ~[main/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:201510201305]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:201510201305]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:201510201305]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) ~[groovy-2.4.4.jar:2.4.4]
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) ~[groovy-2.4.4.jar:2.4.4]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42) [groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:57) [groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) [groovy-2.4.4.jar:2.4.4]
at org.grails.plugins.web.async.WebRequestPromiseDecorator.invokeClosure(WebRequestPromiseDecorator.groovy:43) [grails-plugin-async-3.0.8.jar:3.0.8]
at org.grails.plugins.web.async.WebRequestPromiseDecorator$_decorate_closure1.doCall(WebRequestPromiseDecorator.groovy:30) [grails-plugin-async-3.0.8.jar:3.0.8]
at sun.reflect.GeneratedMethodAccessor285.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:201510201305]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) ~[groovy-2.4.4.jar:2.4.4]
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) ~[groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) ~[groovy-2.4.4.jar:2.4.4]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) ~[groovy-2.4.4.jar:2.4.4]
at groovy.lang.Closure.call(Closure.java:426) [groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:53) [groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:105) [groovy-2.4.4.jar:2.4.4]
at com.sun.proxy.$Proxy74.get(Unknown Source) [na:na]
at reactor.rx.stream.SupplierStream$2.run(SupplierStream.java:82) [reactor-stream-2.0.3.RELEASE.jar:na]
at reactor.core.dispatch.AbstractLifecycleDispatcher$2.accept(AbstractLifecycleDispatcher.java:136) [reactor-core-2.0.3.RELEASE.jar:na]
at reactor.core.dispatch.AbstractLifecycleDispatcher.route(AbstractLifecycleDispatcher.java:159) [reactor-core-2.0.3.RELEASE.jar:na]
at reactor.core.dispatch.SingleThreadDispatcher$SingleThreadTask.run(SingleThreadDispatcher.java:79) [reactor-core-2.0.3.RELEASE.jar:na]
at reactor.core.dispatch.RingBufferDispatcher$3.onEvent(RingBufferDispatcher.java:156) [reactor-core-2.0.3.RELEASE.jar:na]
at reactor.core.dispatch.RingBufferDispatcher$3.onEvent(RingBufferDispatcher.java:153) [reactor-core-2.0.3.RELEASE.jar:na]
at reactor.jarjar.com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:128) [reactor-core-2.0.3.RELEASE.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_65]
at java.lang.Thread.run(Thread.java:745)
It seems this is around hibernate session problem but there's no GORM and I don't know how to prevent it.

SQL Server : returning the related xml with value, nodes methods

I have a the below sample XML schema that I am querying from in SQL Server 2012. I have a table with a XML column. I want to include the snippet of xml when each row is returned.
Below is the existing query and more detailed explanation.
<dev:Doc xmlns:dev="http://www.w3.org/2001/XMLSchema" Number="0" SchemaVersion="0.1" Settings="Testing" Title="Ordering">
<dev:Forms FormId="A1">
<dev:A1 ItemNumber="1" ItemGuid="{F402C584-555E-4D07-8C35-E88889B9DA44}">
<dev:Codes>D</dev:Codes>
<dev:Required>true</dev:Required>
<dev:Informational>false</dev:Informational>
<dev:Visitors>
<dev:Visitor Name="Dev01" Location="STLRF">
<dev:Divisions>
<dev:Division Number="1" Name="TFR3" Usage="Monitor">
<dev:Description>Development Fundamentals</dev:Description>
</dev:Division>
<dev:Division Number="2" Name="DEF32" Usage="Monitor">
<dev:Description>Testing Fundamentals</dev:Description>
</dev:Division>
<dev:Division Number="3" Name="DEP13" Usage="None">
<dev:Description>Guided Fundamentals</dev:Description>
</dev:Division>
</dev:Divisions>
</dev:Visitor>
<dev:Visitor Name="Dev02" Location="STLRF">
<dev:Divisions>
<dev:Division Number="1" Name="TFR3" Usage="Monitor">
<dev:Description>Development Fundamentals</dev:Description>
</dev:Division>
<dev:Division Number="2" Name="DEF32" Usage="Monitor">
<dev:Description>Testing Fundamentals</dev:Description>
</dev:Division>
<dev:Division Number="3" Name="DEP13" Usage="None">
<dev:Description>Guided Fundamentals</dev:Description>
</dev:Division>
</dev:Divisions>
</dev:Visitor>
<dev:Visitor Name="Dev03" Location="FGRTY">
<dev:Divisions>
<dev:Division Number="1" Name="TFR3" Usage="Monitor">
<dev:Description>Development Fundamentals</dev:Description>
</dev:Division>
<dev:Division Number="2" Name="DEF32" Usage="Monitor">
<dev:Description>Testing Fundamentals</dev:Description>
</dev:Division>
<dev:Division Number="3" Name="DEP13" Usage="None">
<dev:Description>Guided Fundamentals</dev:Description>
</dev:Division>
</dev:Divisions>
</dev:Visitor>
</dev:Visitors>
<dev:Senders>
<dev:Sender Name="FGY(14A)" />
</dev:Senders>
</dev:A1>
</dev:Forms>
<dev:Forms FormId="A2">
<dev:A2 ItemNumber="1" ItemGuid="{3563F33E-B03A-4859-850E-A87D35BD8562}">
<dev:Codes>C</dev:Codes>
<dev:Required>true</dev:Required>
<dev:Informational>false</dev:Informational>
<dev:Remarks>Support</dev:Remarks>
<dev:Notes>Ready</dev:Notes>
<dev:Visitors>
<dev:Visitor Name="GHFF">
<dev:Divisions>
<dev:Division Number="0" Name="Trial" Usage="None">
<dev:FromLocation>LOPO</dev:FromLocation>
<dev:ToLocation>RDSS</dev:ToLocation>
<dev:Description>Rich Filter</dev:Description>
</dev:Division>
</dev:Divisions>
</dev:Visitor>
</dev:Visitors>
<dev:Senders>
<dev:Sender Name="W33R" />
</dev:Senders>
<dev:IsReady>true</dev:IsReady>
<dev:IsCall>false</dev:IsCall>
</dev:A2>
<dev:A2 ItemNumber="2" ItemGuid="{CCFB2D5D-A23E-412D-8541-536451873713}">
<dev:Codes>A</dev:Codes>
<dev:Required>true</dev:Required>
<dev:Informational>false</dev:Informational>
<dev:Remarks>Loader Ready</dev:Remarks>
<dev:Notes>Ready</dev:Notes>
<dev:Visitors>
<dev:Visitor Name="UDT">
<dev:Divisions>
<dev:Division Number="0" Name="Trial" Usage="None">
<dev:FromLocation>TYUJ</dev:FromLocation>
<dev:ToLocation>DETF</dev:ToLocation>
<dev:Description>Web Enhance</dev:Description>
</dev:Division>
</dev:Divisions>
</dev:Visitor>
</dev:Visitors>
<dev:Senders>
<dev:Sender Name="RJ4" />
</dev:Senders>
<dev:IsReady>true</dev:IsReady>
<dev:IsCall>false</dev:IsCall>
</dev:A2>
</dev:Forms>
</dev:Doc>
Sample query
;WITH XMLNAMESPACES (Default 'http://www.w3.org/2001/XMLSchema' )
SELECT
a.value('#Number[1]', 'int') as Number
,b.value('(#FormId)[1]', 'NVARCHAR(50)') Form
--,XmlDocument.query('Doc/Forms') as FormXml,
,c.value('#ItemGuid[1]', 'uniqueidentifier') as ItemGuid
,c.value('#ItemNumber[1]', 'INT') AS ItemNumber
,d.value('(#Name)[1]','nvarchar(50)') As Visitor
,d.value('(#Location)[1]','nvarchar(50)') As Location
,e.value('(#Name)[1]', 'NVARCHAR(50)') As Sender
FROM
XmlTable As X
CROSS APPLY XmlDocument.nodes('Doc') As aa(a)
CROSS APPLY a.nodes('Forms') As bb(b)
CROSS APPLY b.nodes('*') As cc(c)
CROSS APPLY c.nodes('Visitors/Visitor') as dd(d)
CROSS APPLY c.nodes('Senders/Sender') as ee(e)
What I would like to do is include the snippet of xml after the Form column to show the snippet it came from.
I am trying this
XmlDocument.query('Doc/Forms') as FormXml,
The above is returning from that element down, I just want to return everything from <dev:Forms FormId="A1"> to the </dev:A1> for each row related to A1. So when Form is A2 I want A2 - /A2 <--- everything between
I believe what you want to get is the XML that is referenced by the b "table", no?
Try this line:
, b.query('.') as FormXml
Does that give you want you're looking for? It should give you the XML of the <Forms> node.

Resources