Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 09 23:04

    jxblum on master

    Refactor test framework infrast… (compare)

  • Apr 09 12:05

    schauder on master

    Switch to lombok.With This rep… (compare)

  • Apr 09 11:23
    wolfdale review_requested #612
  • Apr 09 11:14
    wolfdale synchronize #612
  • Apr 09 10:50

    christophstrobl on master

    Upgrade to MongoDB Java Drivers… (compare)

  • Apr 09 10:43

    odrotbohm on master

    RepositoryRestConfigurer are ag… (compare)

  • Apr 09 10:32

    mp911de on 3601

    (compare)

  • Apr 09 10:32
    mp911de closed #3607
  • Apr 09 10:32

    mp911de on master

    Fix query mapping resolution of… (compare)

  • Apr 09 10:32

    mp911de on 3.1.x

    Fix query mapping resolution of… (compare)

  • Apr 09 10:25
    mp911de labeled #3607
  • Apr 09 09:07

    schauder on 2.2.x

    Upgrade dependencies. Closes #… (compare)

  • Apr 09 09:06

    schauder on 2.3.x

    Upgrade dependencies. Closes #… (compare)

  • Apr 09 09:06

    schauder on 2.4.x

    Upgrade dependencies. Closes #… (compare)

  • Apr 09 09:06

    schauder on master

    Upgrade dependencies. Closes #… (compare)

  • Apr 09 07:37

    mp911de on 2.4.x

    Upgrade to RxJava 3.0.12. See … (compare)

  • Apr 09 07:35

    mp911de on master

    Upgrade to Mockito 3.9.0. See … Upgrade to RxJava 3.0.12. See … (compare)

  • Apr 08 22:18

    sothawo on 4.0.x

    Fix reactive connection handlin… (compare)

  • Apr 08 21:21

    sothawo on 4.1.x

    Fix reactive connection handlin… (compare)

  • Apr 08 20:00

    sothawo on master

    Fix reactive connection handlin… (compare)

Fly-Away
@Fly-Away
if you want destroy the data from the main table but still keep the data somewhere else, there is a tool named "Spring Data Envers" to capture every change on your main table. the other way will be CDC debezium kafka. Right now i am using "Spring Data Envers"
Abhirama Mallela
@kauphylover
Hi, we're using spring-data-redis and are using the pubsub functionality. I've noticed a strange issue where the subscription "goes missing" on redis i.e., the app subscribes successfully but after a while the subscription isn't seen on redis. While trying to troubleshoot, I was looking through the API support in RedisMessageListenerContainer and couldn't find a way to retrieve a set of topics that the app is currently subscribed to (or even the status of each subscription). Any ideas on how I could achieve that? Thanks in advance!
Abhirama Mallela
@kauphylover
Actually, I have to correct myself a little wrt. the above message. It's not just the subscription that "goes missing". It's the topic that "vanishes". So I want to also be able to list all available topics..
Tiago Casinhas
@Heatmanofurioso
Hi, we're trying to do QueryByExample with related entities @ManyToMany relationships, but QueryByExample seems to not filter with the values present in the @ManyToMany. I believe this is a bug, but I though it was wiser to ask here before opening an issue, as I may be wrong. Thanks in advance!
3 replies
Gabriel Popovici
@popovici.gabriel_gitlab
hi folks is there any dedicated channel for spring data couchbase ? much ...much appreciated
Mark Paluch
@mp911de
We don't have dedicated channels per database technology.
Gabriel Popovici
@popovici.gabriel_gitlab
ok
huifer
@huifer
How to delete logic in spring data JPA 2.4.4
1 reply
Burim Krasniqi
@burimkrasniqi

Hi, I'm using Spring Boot Webflux and Mongodb as database. In this project I have two submodules and my problem is related to @TypeAlias and _class generated by Spring data. My problem is that by default _class is taking the name of the entity class which is including the package name and its leading to inconsistency when the same Entity is used in different submodules:

  1. Api - submodule has this class name : com.example.api.MyEntity.class
  2. Worker - submodule has this class name: com.example.worker.MyEntity.class

So my question is how can I configure the base package name com.example.api and com.example.worker to custom.package?
One way is to use @TypeAlias but this is a pain to do for each entity.. Is there any alternative?

Mark Paluch
@mp911de
@burimkrasniqi you can configure your own MongoTypeMapper in MappingMongoConverter to write type keys/resolve types by name as you need it in your application.
Robin Leclerc
@BreadAndRoses_gitlab
Hey everyone, I'm working with spring data elasticsearch 4.1.6 + kotlin, and when I add a @Field(type = FieldType.Date, format = DateFormat.date) to LocalDate field in a nested object it is not used and I get a mapper_parsing_exception, has anyone already faced this issue before?
16 replies
Lukáš Vasek
@bilak
Hello, does spring-data-jdbc support projections? e.g if I want to returnd custom type from query. Something like @Query("select new com.example.UserProjection(u.first_name, u.last_name) from users u where u.id = :id")
10 replies
r-asou
@r-asou
Hello, whats the difference between defining specification/ define methods in repository / using @Query on method in repository especially in performance level
1 reply
Kenneth
@kennywk
I'm having a strange issue. When i deploy an application the first time, everything starts and works fine. When the Wildfly server restarts, Spring Data Mongo hangs on the MongoPersistentEntityIndexCreator checkForIndexes for an entity. If i remove the deployment and deploy again it works.... any ideas? Not seeing any errors or debug messages that helps to find any possible issues.

I'm having a strange issue. When i deploy an application the first time, everything starts and works fine. When the Wildfly server restarts, Spring Data Mongo hangs on the MongoPersistentEntityIndexCreator checkForIndexes for an entity. If i remove the deployment and deploy again it works.... any ideas? Not seeing any errors or debug messages that helps to find any possible issues.

I'm using Spring Data Mongo 2.2.9, Mongo Driver Sync 3.11.2 and Wildfly/Keycloak 11.0.1

revised
@carlmolemans
When is spring data jpa going to rely on the latest persistence & transaction api from jakarta? I cannot seem to find a whole lot of documentation on what "changed" between these versions. If anyone has references (to the api changes) feel free to share them.
Mark Paluch
@mp911de
@carlmolemans you refer to the specs released with changed packages (e.g. jakarta.persistence-api 3.0)? If so, then Spring Framework and all downstream projects (Spring Data, Spring Boot) need to be migrated. Eclipselink 3.0 is available but there's no Hibernate release supporting Jakarta Persistence 3.0 yet.
I think that Jakarta Persistence 3.0 solely consists of the package rename and doesn't contain any features in comparison to JPA 2.2
Kenneth
@kennywk
Anything ideas regarding my issue?
Mark Paluch
@mp911de
Without any additional details (stack trace, error messages, thread dump), we can't really help.
Kenneth
@kennywk
That is the problem... there is none. It does not throw any exception, the only log message is the one i provided, i'll check into a thread dump.
Sebastien Vermeille
@sebastienvermeille

Hello guys, I have a small issue (migrating to springboot 2.4.4) -> Spring Data Redis - Could not safely identify store assignment for repository candidate interface MyJpaRepositoryIf you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash

The problem is that this repository is extending JpaRepository and is supposed to work with Postgresql. The one for Redis have the @RedisHash stuff.

How can I get away of such messages ? Thank you in advance

ismailalabou
@alb_isma_twitter
hello i need some help regarding adding some modification to my spring app: https://imgur.com/a/CgIn3eL
I already tried multiple times, but without any luck

ASAP

surendrarathore
@surendrarathore
@mp911de I am using spring boot 2.3.9.RELEASE with java 8, this application is MultiTenant based application. MultiTenant work fine but problem is rollback not working while one database data insert and 2nd database throw any Exception then rollback not working.
Johan Blomgren
@blommish
Spring-data-jdbc and postgres
If you want to use batchInsert/update, would that be possible in some way without having to create your own RowMappers and use JdbcTemplate?
5 replies
Anders Clausen
@AndersClausen

Hi all. I'm trying to understand something about spring-data-elasticsearch. I'm using the reactive version of it, however I've just run BlockHound from Project Reactor and discovered that some part of the inner logic of FieldSortBuilder is blocking (java.io.FileInputStream#readBytes), so when I trigger the search method on ReactiveElasticsearchOperations with my query, which includes the sorting, I'm getting a blocked call. This is what the output from BlockHound looks like (I've shortened it a bit)

{
  "instant": {
    "epochSecond": 1617007532,
    "nanoOfSecond": 924212200
  },
  "thread": "reactor-http-nio-6",
  "level": "ERROR",
  "loggerName": "org.springframework.web.server.adapter.HttpWebHandlerAdapter",
  "message": "[8acef90c-1] 500 Server Error for HTTP GET \"/shipments?vesselOperatorCarrierCode=MAEI&carrierCustomerCode=331S4019201&limit=100&taskCode=0000000000081&statusCode=2&locationFrom=1MBDCYHT39CNY\"",
  "thrown": {
    "commonElementCount": 0,
    "localizedMessage": "Blocking call! java.io.FileInputStream#readBytes",
    "message": "Blocking call! java.io.FileInputStream#readBytes",
    "name": "reactor.blockhound.BlockingOperationError",
    "extendedStackTrace": [
      {
        "class": "java.io.FileInputStream",
        "method": "readBytes",
        "file": "FileInputStream.java",
        "line": -1,
        "exact": false,
        "location": "?",
        "version": "?"
      }
    ],
    "suppressed": [
      {
        "commonElementCount": 0,
        "localizedMessage": "\nError has been observed at the following site(s):\n\t|_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ HTTP GET \"/shipments?vesselOperatorCarrierCode=MAEI&carrierCustomerCode=331S4019201&limit=100&taskCode=0000000000081&statusCode=2&locationFrom=1MBDCYHT39CNY\" [ExceptionHandlingWebHandler]\nStack trace:",
        "message": "\nError has been observed at the following site(s):\n\t|_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ HTTP GET \"/shipments?vesselOperatorCarrierCode=MAEI&carrierCustomerCode=331S4019201&limit=100&taskCode=0000000000081&statusCode=2&locationFrom=1MBDCYHT39CNY\" [ExceptionHandlingWebHandler]\nStack trace:",
        "name": "reactor.core.publisher.FluxOnAssembly$OnAssemblyException",
        "extendedStackTrace": [
          {
            "class": "java.io.FileInputStream",
            "method": "readBytes",
            "file": "FileInputStream.java",
            "line": -1,
            "exact": false,
            "location": "?",
            "version": "?"
          },
          {
            "class": "org.elasticsearch.Build",
            "method": "<clinit>",
            "file": "Build.java",
            "line": 143,
            "exact": false,
            "location": "elasticsearch-7.9.3.jar",
            "version": "7.9.3"
          },
          {
            "class": "org.elasticsearch.common.logging.DeprecationLogger",
            "method": "<clinit>",
            "file": "DeprecationLogger.java",
            "line": 148,
            "exact": false,
            "location": "elasticsearch-7.9.3.jar",
            "version": "7.9.3"
          },
          {
            "class": "org.elasticsearch.search.sort.FieldSortBuilder",
            "method": "<clinit>",
            "file": "FieldSortBuilder.java",
            "line": 73,
            "exact": false,
            "location": "elasticsearch-7.9.3.jar",
            "version": "7.9.3"
          },
          {
            "class": "org.elasticsearch.search.sort.SortBuilders",
            "method": "fieldSort",
            "file": "SortBuilders.java",
            "line": 46,
            "exact": false,
            "location": "elasticsearch-7.9.3.jar",
            "version": "7.9.3"
          }
        ]
      }
    ]
  }
}

Is this expected or should I do something different? Thank you

6 replies
acaciobrito
@acaciobrito

Hello, I am using spring-data-mongodb
But I need to use ssl to connect to the mongoDB server.

I did not find any documentation on how to do it. I have .pem file but I can't find a way to use it. Could someone help me with this?

1 reply
Sebastien Vermeille
@sebastienvermeille

Hello, I have 7 repositories (2 Redis, 5 JPA)
I used specific base package with filter for all of them in annoattions (@EnableSpringRedis() @EnableSpringJpa() so that spring data have no confusion
But at startup this takes more than 3 minutes:

RepositoryConfigurationDelegate.multipleStoresDetected: Multiple Spring Data modules found, entering strict repository configuration mode!
RepositoryConfigurationDelegate.registerRepositoriesIn:
                Bootstrapping Spring Data Redis repositories in DEFAULT mode. // < --------- this takes 3 minutes

RepositoryConfigurationDelegate.registerRepositoriesIn:
                Finished Spring Data repository scanning in 303059 ms. Found 2 Redis repository interfaces.
RepositoryConfigurationDelegate.registerRepositoriesIn:
                Finished Spring Data repository scanning in 77 ms. Found 5 JPA repository interfaces.

why is it so slow ? (Migrated to last version of spring 2.4.4 (and it takes spring-data-redis 2.4.6)

thank you in advance

9 replies
Jack Wilkinson
@guacjack

Hey all,

Im quite new to Spring Data and working with Databases in general and was just wondering how you might go about solving a specific issue. With Spring Data and with MongoDB (I anticipate the database is not so relevant here)

I have this code

    Optional<Parent> optionalParent = parentRepository.findById("someId");

    if (optionalParent.isPresent()) {
        Parent parent = optionalParent.get();
        Child child = new Child("some value");
        parent.getChildren().add(child);
        parentRepository.save(parent);
    }

The issue is that, if there were multiple threads or instances which are running this code then there maybe a concurrency issue as the "Get the parent", "Add child to parent" and "Save Parent" stages together are not atomic and therefore could end up with child's being overwritten.

How would this situation normally be resolved?

Jack Wilkinson
@guacjack
I appreciate my above message is not at all Spring Data specific however I just wanted to ask more experienced people how they would normally solve that issue :)
Mark Paluch
@mp911de
@guacjack Use optimistic locking. Adding a @Version property to your document entity will let Spring Data consider the current version of your document. Each update increments the version. On a concurrent update, there can be only one winner and the other one will receive an OptimisticLockingFailureException. Spring Data MongoDB adds the version number to the update filter and checks how many documents were updated. Does that help?
Jack Wilkinson
@guacjack
@mp911de that really helps. I've done something similar with optimistic locking in Couchbase before (just not with Spring) where you would use a CAS (Compare and swap) value to check if someone has jumped in with a change before you which sounds very much like what you have just mentioned.
Jack Wilkinson
@guacjack
@mp911de just checking now, so by using the @Version annotation along with a version property, that means the version actually gets persisted to the document, rather than being some type of meta-data on the document?
3 replies
slenz
@slenz:privacytools.io
[m]

Hello,
I'm using spring-data-rest with QueryDsl, and I'm experiencing weird behaviour.

With the filter http://my.service/users?roles=2&roles=5, I'm getting all users with roles 2 AND 5.
With the filter http://my.service/users?roles.id=2&roles.id=5, I'm getting all users with roles 2 OR 5.

The reason lies in QuerydslDefaultBinding.java since the first path ends up in the CollectionPathBase branch and the second in the SimpleExpression branch.

While I like that I have both options, I find this very unintuitive. I would have guessed, that the first query would be just a shorthand for the second.

I'm now wondering what is the rationale behind this behaviour.

Regards

Ali Mujthaba
@a-mujthaba321
How to simulate a long running sql query using spring data repository?
@Query(value = "SELECT 1 WAITFOR DELAY '0:05'")
void waitforSQL();
1 reply
This gives an unexpected token error
Anders Clausen
@AndersClausen

Hi Mark @mp911de. I seem to have a problem with spring-data-elasticsearch (SDE) when going from spring-boot 2.4.4 (4.1.6 SDE) to 2.5.0-M3 (4.2.0-M5 SDE). Some of the fields in one of my domain classes is defined like this:

@Field(name = FIELD_VERSION_UPDATE_TIME, type = FieldType.Date, format = DateFormat.date_optional_time)
private LocalDateTime versionUpdateTime;

and I'm now getting errors like org.springframework.data.elasticsearch.core.convert.ConversionException: could not create object of class java.time.LocalDateTime when running my tests. Is there something extra I need to specify with the dateformat? Thanks for your help

2 replies
John G
@jgolubenko

Hi all, I have anyone seen this RE:

Factory method 'restHandlerMapping' threw exception; nested exception is java.lang.IllegalStateException: Invalid mapping on handler class [org.springframework.data.rest.webmvc.RepositoryController]: public org.springframework.http.ResponseEntity org.springframework.data.rest.webmvc.RepositoryController.headForRepositories()

Using spring-data-rest-core-3.4.5, spring-data-rest-webmvc-3.4.5, spring-core-5.3.2

Caused by: java.lang.NoSuchMethodError: org.springframework.web.servlet.mvc.method.RequestMappingInfo.mutate()Lorg/springframework/web/servlet/mvc/method/RequestMappingInfo$Builder;
    at org.springframework.data.rest.webmvc.BasePathAwareHandlerMapping.getMappingForMethod(BasePathAwareHandlerMapping.java:128) ~[spring-data-rest-webmvc-3.4.5.jar:3.4.5]
    at org.springframework.data.rest.webmvc.BasePathAwareHandlerMapping.getMappingForMethod(BasePathAwareHandlerMapping.java:47) ~[spring-data-rest-webmvc-3.4.5.jar:3.4.5]
    at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lambda$detectHandlerMethods$1(AbstractHandlerMethodMapping.java:274) ~[spring-webmvc-5.3.2.jar:5.3.2]
    ... 77 common frames omitted
Looks like it's lib version mismatch, but I'm given https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html spring 5.3.4 should be compatible with spring-data-rest 3.4.5
garramja
@garramja

I have lettuce client with springboot 2.3.9.RELEASE to connect AWS redis elasticcache master/slave.
I'am able to write and read but a error is thrown every 5000ms

The service works fine for my pourpose but I want to remove the error or how to know to fix it.

I've read a lot about it and the best way to configure spring data redis with lettuce ans AWS is using RedisStaticMasterReplicaConfiguration to write to master and read from replica.

This is the bean configuration

    @Bean
    public LettuceConnectionFactory redisConnectionFactory() {

        LettuceClientConfiguration.LettuceClientConfigurationBuilder lettuceConfigBuilder = LettuceClientConfiguration.builder()
                .readFrom(ReadFrom.REPLICA_PREFERRED);
        lettuceConfigBuilder.useSsl();

        RedisStaticMasterReplicaConfiguration redisConfiguration = new RedisStaticMasterReplicaConfiguration(master, port); //master value is the Primary Endpoint value from aws elasticcache info
        redisConfiguration.addNode(replica, port); //replica value is the Reader Endpoint value from aws elasticcache info
        redisConfiguration.setPassword(password);

        return new LettuceConnectionFactory(redisConfiguration, lettuceConfigBuilder.build());
    }

When application is started I'm able to write and read but every 5 seconds an error is thrown from RedisMessageListenerContainer

"level":"ERROR","className":"org.springframework.data.redis.listener.RedisMessageListenerContainer","message":"Connection failure occurred. Restarting subscription task after 5000 ms "

But this is the original error from RedisMessageListenerContainer.handleSubscriptionException

java.lang.UnsupportedOperationException: Pub/Sub connections not supported with Master/Replica configurations
Anders Clausen
@AndersClausen

Good evening all. I need some help with the health check of Elasticsearch. I'm using Spring Boot 2.5.0-M3 and spring-data-elasticsearch 4.2.0-M5 and I'm using the ReactiveElasticsearchClient.
When checking /actuator/health locally it works fine, however after I've deployed to Kubernetes the heath check keeps reporting

elasticsearch: {
   status: "DOWN",
   details: {
   statusCode: 401,
   reasonPhrase: "Unauthorized"
}

I have set the following properties but without any luck.

spring:
  elasticsearch:
    rest:
      uris: ${ELASTICSEARCH_HOST}
      password: ${ELASTICSEARCH_PWD}
      username: ${ELASTICSEARCH_USER}

I can use those credentials and successfully call the /_cluster/health endpoint through Postman, so why does it give me a 401 when Spring Boot tries to call?
Am I missing something? Thank you

17 replies
Syed Mainul Hasan
@mainul35
how to work with one-to-many relations in Spring reactive data?
Nilesh Sargar
@nsargar
Hi, I am new to r2dbc and I am trying to fetch data using projection (r2dbcTemplate.select.as()) but not able to apply the distinct, searched a lot but no luck, can anyone please point me in a direction. Thanks in advance.
Jfrs
@jfrs
Hello, I'm trying to get the equivalent of @Query("DELETE FROM SESSION_CLIP WHERE SESSION = :session") with the following derived delete query void deleteBySession(UUID session);, which raises the following exception when executed: NoSuchMethodException: void.<init>(). It seems to have something to do with a missing default constructor, but I'm not sure why that would be needed here?
sasa-fajkovic
@sasa-fajkovic

Hi All,

I'm looking for ideas what's the best approach when storing data using DATA JPA and using Kotlin.
Entity example

@Entity(name = "COUNTRIES")
data class Country(
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    val id: Long = 0,
    val name: String,
    val countryCode: String,
    val flagUrl: String? = null,

    @OneToMany(mappedBy = "country")
    val venues: Set<Venue> = setOf(),

    @OneToMany(mappedBy = "country")
    val teams: Set<Team> = setOf(),

    @OneToMany(mappedBy = "country")
    val leagues: Set<League> = setOf()
)

I wanna store the entity while providing only the name, countryCode and flagUrl.

Ideas I came up with:

  1. set venues, teams, and leagues as nullable and set default value as null.
  2. move those 3 properties to the body of the class instead of keeping it in the constructor.
  3. Keep as is and set the default value as empty Set.

Any other ideas or an idea what would be the best approach?