Teiid Spring Boot #SelectQuery - spring-boot

I have configured 2 different data souces in my Teiid Spring Boot Application and have been following this example:
https://github.com/teiid/teiid-spring-boot/blob/master/docs/UserGuide.adoc
This example demonstrates a union query from Customer table from two different data sources, however, when i run my application the customerrepository retrieves records only from one database and not from the other.
I have uploaded my source code on github:
https://github.com/purnimadas27/TeiidExample1/tree/master/TeiidSpringBootPrj5
Can someone suggest why is my union query not retrieving results as expected, it appears that the customerrepository is bound to only one of the datasource and is retrieving results only from one datasource and it also appears that #SelectQuery is not being considered at all.
Any help is greatly appreciated, thank you!

See this full example here with updated document
Updated: I could not figure out root issue is, this was not occurring with latest code, so wrote a new example with 1.3.1 release of the Teiid Spring Boot. This should work.

Related

How to split GraphQL schema on the server side (spring boot application)

I want to logically separate all my Graphql schemas into diff. entities. I am doing this in a spring-boot project.
I do not want to use Appolo or any other 3rd party libraries.
E.g.
book.graphql
author.graphql
I tried the solution provided, and I got no compile error but I am also not getting results from the query anymore.
Spring GraphQLmultiple schemas with Query per file
Please see below:
Can someone pls point me out if I am doing something incorrectly?
The solution provided here enter link description here works as is.
The reason I was getting errors was that I had not implemented the endpoint.

Latest by group query using Spring Boot JPA

I am using Spring Boot 2.5.0 for one of my test projects and need to get some data from one of the transaction tables. I need only latest record per group from this table. This problem has a solution given multiple times on SO, one of which is https://stackoverflow.com/a/1313293/841221.
However, I want to implement the same using Spring Boot Data JPA and not using a native query as using a native query would make me lose database independence.
Can someone please help me?

Spring Boot - Replicating the EntityManager created by Spring-boot

I've been working on a Spring Boot project and i did all my database operations with the help of Spring Data JPA. So all i had was some entities and some repositories and all the CRUD operations worked fine.
But now, the project needed to talk to 2 databases. So what i did was i created all the new entities and repositories in a separate package. I noticed that now i need to have 2 EntityManagers, so i created 2 config files for both of the entity managers, configuring a datasource, an entityManager and a transactionManager. So now, instead of having 1 entityManager that spring boot gave me, i had 2 entityManagers that i created myself. And they worked fine, they both talked to the database they were supposed to talk to.
My problem is that i seem to have lost a lot of feature in my entityManager that spring-boot previously gave me. For example, my entity manager no longer created the schema based on its entities in my tests, which it previously did. Along with this, i am sure that i will run into other situations in which my entityManager will not be as properly configured as the one spring-boot would have given me.
So my idea was to only declare the second entity manager, and leave the config for the first one empty, however this did not work, and looking into JpaBaseConfiguration i noticed that spring will only create an entityManager if you do not already have one.
#ConditionalOnMissingBean({ LocalContainerEntityManagerFactoryBean.class,
EntityManagerFactory.class })
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
//some code that will give you an entity manager
);
And seeing as i MUST configure a second entityManager for the second database, it looks like im forced to create the first one as well, since spring-boot will skip creating one.
Which leads me to my question:
Is there anyway that i can configure my first entity manager the same way that spring-boot would have done it for me? Or perhaps can i force spring to give me that entityManager even though i have another one declared for the second database? Is there any other way of solving my situation (i am thinking about just using a JDBCTemplate for the second database, however this is kinda of admiting defeat :'( )?
Sorry for the long question. Any answer is appreciated! Thank you!

Spring JPA selecting specific columns by condoition

How to find data that equals to workId and not equals to employeeId using spring data jpa.I searched in google but I did not find any method.I tried findByWorkIdAndNotEqualEmployeeId. But it is not working .So please help me
Actually there's is very good official documentation about Query Creation in spring data jpa
According to it this one should work:
findByWorkIdAndEmployeeIdNot

Spring data and multiple schema config

I'm trying to configure spring boot 1.3.5 + spring data with one datasource and multiples schemas. I've read a lot of post but none helped me.
I want that each costumer has it own schema and i want to create it at a runtime as soon as the new client costumer.
Can someone put an example to help me do it?

Resources