Is it possible to implement a POJO in Spring Boot that has a field representing a composite primary key while not utilizing JPA or nested classes?Spring Data Jpa - Composite primary key issueHow to save a Spring Data JPA entity with a composite keyPersisting a complex @Embeddable using Hibernate/JPAEnforcing primary key constraint in Spring JPADoes Spring Data PagingAndSortingRepository for JPA objects work for composite primary keysSpring Boot Spring Data JPA - Don't scan for Implemented classesShared field in composite primary key for foreign keysspring boot ignore field dynamically jpaJPA/Spring-boot Duplicate entry for key 'PRIMARY'

Why are Hobbits so fond of mushrooms?

Was I subtly told to resign?

Did the Vulgar Latin verb "toccare" exist?

How can one write good dialogue in a story without sounding wooden?

How were Martello towers supposed to work?

Graduate student with abysmal English writing skills, how to help

Why do people keep referring to Leia as Princess Leia, even after the destruction of Alderaan?

Why are they 'nude photos'?

Why were Er and Onan punished if they were under 20?

What's the minimum number of sensors for a hobby GPS waypoint-following UAV?

US Civil War story: man hanged from a bridge

Is "I do not want you to go nowhere" a case of "DOUBLE-NEGATIVES" as claimed by Grammarly?

How many hours would it take to watch all of Doctor Who?

Is there any word for "disobedience to God"?

What is this triple-transistor arrangement called?

Referring to different instances of the same character in time travel

Terry Pratchett book with a lawyer dragon and sheep

Cracking the Coding Interview — 1.5 One Away

Why isn't pressure filtration popular compared to vacuum filtration?

Can fluent English speakers distinguish “steel”, “still” and “steal”?

As the Dungeon Master, how do I handle a player that insists on a specific class when I already know that choice will cause issues?

Do you know your 'KVZ's?

How can I get a player to accept that they should stop trying to pull stunts without thinking them through first?

How to memorize multiple pieces?



Is it possible to implement a POJO in Spring Boot that has a field representing a composite primary key while not utilizing JPA or nested classes?


Spring Data Jpa - Composite primary key issueHow to save a Spring Data JPA entity with a composite keyPersisting a complex @Embeddable using Hibernate/JPAEnforcing primary key constraint in Spring JPADoes Spring Data PagingAndSortingRepository for JPA objects work for composite primary keysSpring Boot Spring Data JPA - Don't scan for Implemented classesShared field in composite primary key for foreign keysspring boot ignore field dynamically jpaJPA/Spring-boot Duplicate entry for key 'PRIMARY'






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I am currently trying to implement R2DBC within Spring Boot for an application that is already far into development - meaning, unfortunately, our DDL is not flexible, since other microservices depend on this it and vice versa. One significant limitation of R2DBC is that is does not support nested classes. Moreover, it does not support JPA, since that would would defeat the purpose of being all-around non-blocking. So all those useful annotations are off the table as well.



The class I am dealing with looks something like this:



@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString

public class Stats
@Id
StatsPK statsPK

@Column(stat_name)
String stat;

...

@Data
@AllArgsConstructor
@NoArgsConstructor
@Embeddable
public static class StatsPK implements Serializable
@Column("store_id")
private Integer storeId;

@Column("empl_id")
private String emplId;

@Column("app_version")
private String appVersion;




After researching my question, I have found many ways to go about accounting for the composite key, including what is already been shown in the example above (using the @Embeddable annotation), using a custom PK object (which is similar, but would have the option of using a class designed for this purpse, such as CompositeKeyHolder), The JPA @TableId(TableId.class) annotation, and some others that seemed less promising.



All of these options seem to either be utilizing JPA or utilizing a nested object, which I cannot do. I can't really think of a way to get around these limitations. But since I'm a beginner, I decided to ask in case anyone has dealt with this issue before.
Appreciate any feedback.










share|improve this question






















  • "microservices depend on this it and vice versa." You don't have Microservices. You have a distributed monolith.

    – Jens Schauder
    Mar 26 at 6:22











  • Would you mind clarifying how you gathered that from the example given? I am not necessarily disagreeing, but I was having trouble making the distinction myself. Bear in mind I use the word 'dependent' loosely, as this is a service that audits the information gathered from several other services.

    – Christian Meyer
    Mar 26 at 18:48











  • The benefit of microservices is independent deployment. You can't do independent deployments if multiple services access the same database. Hence you don't really have independent microservice but one app that happens to be deployed as multiple artifacts.

    – Jens Schauder
    Mar 26 at 19:24






  • 1





    Ah yeah I definitely see that now. I was conceptualizing this service and its counterpart to be a sort of monolith within a microservice (at least, probably not the right way to word it). And that's because this service is sharing a database with one other service, but together they are sending and receiving messages to and from other services that store to their own database(s). Ty for clarification though.

    – Christian Meyer
    Mar 27 at 2:41

















2















I am currently trying to implement R2DBC within Spring Boot for an application that is already far into development - meaning, unfortunately, our DDL is not flexible, since other microservices depend on this it and vice versa. One significant limitation of R2DBC is that is does not support nested classes. Moreover, it does not support JPA, since that would would defeat the purpose of being all-around non-blocking. So all those useful annotations are off the table as well.



The class I am dealing with looks something like this:



@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString

public class Stats
@Id
StatsPK statsPK

@Column(stat_name)
String stat;

...

@Data
@AllArgsConstructor
@NoArgsConstructor
@Embeddable
public static class StatsPK implements Serializable
@Column("store_id")
private Integer storeId;

@Column("empl_id")
private String emplId;

@Column("app_version")
private String appVersion;




After researching my question, I have found many ways to go about accounting for the composite key, including what is already been shown in the example above (using the @Embeddable annotation), using a custom PK object (which is similar, but would have the option of using a class designed for this purpse, such as CompositeKeyHolder), The JPA @TableId(TableId.class) annotation, and some others that seemed less promising.



All of these options seem to either be utilizing JPA or utilizing a nested object, which I cannot do. I can't really think of a way to get around these limitations. But since I'm a beginner, I decided to ask in case anyone has dealt with this issue before.
Appreciate any feedback.










share|improve this question






















  • "microservices depend on this it and vice versa." You don't have Microservices. You have a distributed monolith.

    – Jens Schauder
    Mar 26 at 6:22











  • Would you mind clarifying how you gathered that from the example given? I am not necessarily disagreeing, but I was having trouble making the distinction myself. Bear in mind I use the word 'dependent' loosely, as this is a service that audits the information gathered from several other services.

    – Christian Meyer
    Mar 26 at 18:48











  • The benefit of microservices is independent deployment. You can't do independent deployments if multiple services access the same database. Hence you don't really have independent microservice but one app that happens to be deployed as multiple artifacts.

    – Jens Schauder
    Mar 26 at 19:24






  • 1





    Ah yeah I definitely see that now. I was conceptualizing this service and its counterpart to be a sort of monolith within a microservice (at least, probably not the right way to word it). And that's because this service is sharing a database with one other service, but together they are sending and receiving messages to and from other services that store to their own database(s). Ty for clarification though.

    – Christian Meyer
    Mar 27 at 2:41













2












2








2








I am currently trying to implement R2DBC within Spring Boot for an application that is already far into development - meaning, unfortunately, our DDL is not flexible, since other microservices depend on this it and vice versa. One significant limitation of R2DBC is that is does not support nested classes. Moreover, it does not support JPA, since that would would defeat the purpose of being all-around non-blocking. So all those useful annotations are off the table as well.



The class I am dealing with looks something like this:



@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString

public class Stats
@Id
StatsPK statsPK

@Column(stat_name)
String stat;

...

@Data
@AllArgsConstructor
@NoArgsConstructor
@Embeddable
public static class StatsPK implements Serializable
@Column("store_id")
private Integer storeId;

@Column("empl_id")
private String emplId;

@Column("app_version")
private String appVersion;




After researching my question, I have found many ways to go about accounting for the composite key, including what is already been shown in the example above (using the @Embeddable annotation), using a custom PK object (which is similar, but would have the option of using a class designed for this purpse, such as CompositeKeyHolder), The JPA @TableId(TableId.class) annotation, and some others that seemed less promising.



All of these options seem to either be utilizing JPA or utilizing a nested object, which I cannot do. I can't really think of a way to get around these limitations. But since I'm a beginner, I decided to ask in case anyone has dealt with this issue before.
Appreciate any feedback.










share|improve this question














I am currently trying to implement R2DBC within Spring Boot for an application that is already far into development - meaning, unfortunately, our DDL is not flexible, since other microservices depend on this it and vice versa. One significant limitation of R2DBC is that is does not support nested classes. Moreover, it does not support JPA, since that would would defeat the purpose of being all-around non-blocking. So all those useful annotations are off the table as well.



The class I am dealing with looks something like this:



@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString

public class Stats
@Id
StatsPK statsPK

@Column(stat_name)
String stat;

...

@Data
@AllArgsConstructor
@NoArgsConstructor
@Embeddable
public static class StatsPK implements Serializable
@Column("store_id")
private Integer storeId;

@Column("empl_id")
private String emplId;

@Column("app_version")
private String appVersion;




After researching my question, I have found many ways to go about accounting for the composite key, including what is already been shown in the example above (using the @Embeddable annotation), using a custom PK object (which is similar, but would have the option of using a class designed for this purpse, such as CompositeKeyHolder), The JPA @TableId(TableId.class) annotation, and some others that seemed less promising.



All of these options seem to either be utilizing JPA or utilizing a nested object, which I cannot do. I can't really think of a way to get around these limitations. But since I'm a beginner, I decided to ask in case anyone has dealt with this issue before.
Appreciate any feedback.







spring-data-jpa spring-data pojo r2dbc spring-data-r2dbc






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 2:39









Christian MeyerChristian Meyer

958 bronze badges




958 bronze badges












  • "microservices depend on this it and vice versa." You don't have Microservices. You have a distributed monolith.

    – Jens Schauder
    Mar 26 at 6:22











  • Would you mind clarifying how you gathered that from the example given? I am not necessarily disagreeing, but I was having trouble making the distinction myself. Bear in mind I use the word 'dependent' loosely, as this is a service that audits the information gathered from several other services.

    – Christian Meyer
    Mar 26 at 18:48











  • The benefit of microservices is independent deployment. You can't do independent deployments if multiple services access the same database. Hence you don't really have independent microservice but one app that happens to be deployed as multiple artifacts.

    – Jens Schauder
    Mar 26 at 19:24






  • 1





    Ah yeah I definitely see that now. I was conceptualizing this service and its counterpart to be a sort of monolith within a microservice (at least, probably not the right way to word it). And that's because this service is sharing a database with one other service, but together they are sending and receiving messages to and from other services that store to their own database(s). Ty for clarification though.

    – Christian Meyer
    Mar 27 at 2:41

















  • "microservices depend on this it and vice versa." You don't have Microservices. You have a distributed monolith.

    – Jens Schauder
    Mar 26 at 6:22











  • Would you mind clarifying how you gathered that from the example given? I am not necessarily disagreeing, but I was having trouble making the distinction myself. Bear in mind I use the word 'dependent' loosely, as this is a service that audits the information gathered from several other services.

    – Christian Meyer
    Mar 26 at 18:48











  • The benefit of microservices is independent deployment. You can't do independent deployments if multiple services access the same database. Hence you don't really have independent microservice but one app that happens to be deployed as multiple artifacts.

    – Jens Schauder
    Mar 26 at 19:24






  • 1





    Ah yeah I definitely see that now. I was conceptualizing this service and its counterpart to be a sort of monolith within a microservice (at least, probably not the right way to word it). And that's because this service is sharing a database with one other service, but together they are sending and receiving messages to and from other services that store to their own database(s). Ty for clarification though.

    – Christian Meyer
    Mar 27 at 2:41
















"microservices depend on this it and vice versa." You don't have Microservices. You have a distributed monolith.

– Jens Schauder
Mar 26 at 6:22





"microservices depend on this it and vice versa." You don't have Microservices. You have a distributed monolith.

– Jens Schauder
Mar 26 at 6:22













Would you mind clarifying how you gathered that from the example given? I am not necessarily disagreeing, but I was having trouble making the distinction myself. Bear in mind I use the word 'dependent' loosely, as this is a service that audits the information gathered from several other services.

– Christian Meyer
Mar 26 at 18:48





Would you mind clarifying how you gathered that from the example given? I am not necessarily disagreeing, but I was having trouble making the distinction myself. Bear in mind I use the word 'dependent' loosely, as this is a service that audits the information gathered from several other services.

– Christian Meyer
Mar 26 at 18:48













The benefit of microservices is independent deployment. You can't do independent deployments if multiple services access the same database. Hence you don't really have independent microservice but one app that happens to be deployed as multiple artifacts.

– Jens Schauder
Mar 26 at 19:24





The benefit of microservices is independent deployment. You can't do independent deployments if multiple services access the same database. Hence you don't really have independent microservice but one app that happens to be deployed as multiple artifacts.

– Jens Schauder
Mar 26 at 19:24




1




1





Ah yeah I definitely see that now. I was conceptualizing this service and its counterpart to be a sort of monolith within a microservice (at least, probably not the right way to word it). And that's because this service is sharing a database with one other service, but together they are sending and receiving messages to and from other services that store to their own database(s). Ty for clarification though.

– Christian Meyer
Mar 27 at 2:41





Ah yeah I definitely see that now. I was conceptualizing this service and its counterpart to be a sort of monolith within a microservice (at least, probably not the right way to word it). And that's because this service is sharing a database with one other service, but together they are sending and receiving messages to and from other services that store to their own database(s). Ty for clarification though.

– Christian Meyer
Mar 27 at 2:41












1 Answer
1






active

oldest

votes


















1














Spring Data R2DBCs repository abstraction does not support composite keys yet.
What you could use the DatabaseClient though to construct your SQL and to query data.






share|improve this answer























  • Ok, so far I have been using the DatabaseClient and Connection from MssqlFactory. But given that the only reason I want to utilize R2DBC is to reduce load and increase performance, I would be more trusting of the R2dbcRepository over my own SQL queries. Still, it's nice to hear that I'm on the right track given what I have to work with. Thanks for feedback.

    – Christian Meyer
    Mar 26 at 18:54










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349082%2fis-it-possible-to-implement-a-pojo-in-spring-boot-that-has-a-field-representing%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Spring Data R2DBCs repository abstraction does not support composite keys yet.
What you could use the DatabaseClient though to construct your SQL and to query data.






share|improve this answer























  • Ok, so far I have been using the DatabaseClient and Connection from MssqlFactory. But given that the only reason I want to utilize R2DBC is to reduce load and increase performance, I would be more trusting of the R2dbcRepository over my own SQL queries. Still, it's nice to hear that I'm on the right track given what I have to work with. Thanks for feedback.

    – Christian Meyer
    Mar 26 at 18:54















1














Spring Data R2DBCs repository abstraction does not support composite keys yet.
What you could use the DatabaseClient though to construct your SQL and to query data.






share|improve this answer























  • Ok, so far I have been using the DatabaseClient and Connection from MssqlFactory. But given that the only reason I want to utilize R2DBC is to reduce load and increase performance, I would be more trusting of the R2dbcRepository over my own SQL queries. Still, it's nice to hear that I'm on the right track given what I have to work with. Thanks for feedback.

    – Christian Meyer
    Mar 26 at 18:54













1












1








1







Spring Data R2DBCs repository abstraction does not support composite keys yet.
What you could use the DatabaseClient though to construct your SQL and to query data.






share|improve this answer













Spring Data R2DBCs repository abstraction does not support composite keys yet.
What you could use the DatabaseClient though to construct your SQL and to query data.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 26 at 6:28









Jens SchauderJens Schauder

48.8k18 gold badges119 silver badges250 bronze badges




48.8k18 gold badges119 silver badges250 bronze badges












  • Ok, so far I have been using the DatabaseClient and Connection from MssqlFactory. But given that the only reason I want to utilize R2DBC is to reduce load and increase performance, I would be more trusting of the R2dbcRepository over my own SQL queries. Still, it's nice to hear that I'm on the right track given what I have to work with. Thanks for feedback.

    – Christian Meyer
    Mar 26 at 18:54

















  • Ok, so far I have been using the DatabaseClient and Connection from MssqlFactory. But given that the only reason I want to utilize R2DBC is to reduce load and increase performance, I would be more trusting of the R2dbcRepository over my own SQL queries. Still, it's nice to hear that I'm on the right track given what I have to work with. Thanks for feedback.

    – Christian Meyer
    Mar 26 at 18:54
















Ok, so far I have been using the DatabaseClient and Connection from MssqlFactory. But given that the only reason I want to utilize R2DBC is to reduce load and increase performance, I would be more trusting of the R2dbcRepository over my own SQL queries. Still, it's nice to hear that I'm on the right track given what I have to work with. Thanks for feedback.

– Christian Meyer
Mar 26 at 18:54





Ok, so far I have been using the DatabaseClient and Connection from MssqlFactory. But given that the only reason I want to utilize R2DBC is to reduce load and increase performance, I would be more trusting of the R2dbcRepository over my own SQL queries. Still, it's nice to hear that I'm on the right track given what I have to work with. Thanks for feedback.

– Christian Meyer
Mar 26 at 18:54








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349082%2fis-it-possible-to-implement-a-pojo-in-spring-boot-that-has-a-field-representing%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript