2323import jakarta .persistence .Table ;
2424
2525
26+
2627public class LazyOneToOneWithJoinColumnTest extends BaseReactiveTest {
2728
2829 @ Override
@@ -34,41 +35,41 @@ protected Collection<Class<?>> annotatedEntities() {
3435 public void testLoad (TestContext context ) {
3536 final Endpoint endpoint = new Endpoint ();
3637 final EndpointWebhook webhook = new EndpointWebhook ();
37- endpoint .webhook = webhook ;
38- webhook .endpoint = endpoint ;
38+ endpoint .setWebhook ( webhook ) ;
39+ webhook .setEndpoint ( endpoint ) ;
3940
4041 test ( context , openMutinySession ()
4142 .chain ( session -> session
4243 .persist ( endpoint )
4344 .chain ( session ::flush ) )
4445 .chain ( this ::openMutinySession )
4546 .chain ( session -> session
46- .find ( Endpoint .class , endpoint .id )
47+ .find ( Endpoint .class , endpoint .getId () )
4748 .invoke ( optionalAnEntity -> {
4849 context .assertNotNull ( optionalAnEntity );
49- context .assertNotNull ( optionalAnEntity .webhook );
50+ context .assertNotNull ( optionalAnEntity .getWebhook () );
5051 // This is eager because the other table contains the reference
51- context .assertTrue ( Hibernate .isInitialized ( optionalAnEntity .webhook ) );
52+ context .assertTrue ( Hibernate .isInitialized ( optionalAnEntity .getWebhook () ) );
5253 } ) )
5354 .chain ( this ::openMutinySession )
5455 .chain ( session -> session
55- .find ( EndpointWebhook .class , webhook .id )
56+ .find ( EndpointWebhook .class , webhook .getId () )
5657 .invoke ( optionalAnEntity -> {
5758 context .assertNotNull ( optionalAnEntity );
58- context .assertNotNull ( optionalAnEntity .endpoint );
59- // This i actually lazy
60- context .assertFalse ( Hibernate .isInitialized ( optionalAnEntity .endpoint ) );
59+ context .assertNotNull ( optionalAnEntity .getEndpoint () );
60+ // This is actually lazy
61+ context .assertFalse ( Hibernate .isInitialized ( optionalAnEntity .getEndpoint () ) );
6162 } ) )
6263 );
6364 }
6465
6566 @ Test
6667 public void testQuery (TestContext context ) {
6768 final Endpoint endpoint = new Endpoint ();
68- endpoint .accountId = "XYZ_123" ;
69+ endpoint .setAccountId ( "XYZ_123" ) ;
6970 final EndpointWebhook webhook = new EndpointWebhook ();
70- endpoint .webhook = webhook ;
71- webhook .endpoint = endpoint ;
71+ endpoint .setWebhook ( webhook ) ;
72+ webhook .setEndpoint ( endpoint ) ;
7273
7374 String query = "FROM Endpoint WHERE id = :id AND accountId = :accountId" ;
7475 test ( context , openMutinySession ()
@@ -78,14 +79,14 @@ public void testQuery(TestContext context) {
7879 .chain ( this ::openMutinySession )
7980 .chain ( session -> session
8081 .createQuery ( query , Endpoint .class )
81- .setParameter ( "id" , endpoint .id )
82- .setParameter ( "accountId" , endpoint .accountId )
82+ .setParameter ( "id" , endpoint .getId () )
83+ .setParameter ( "accountId" , endpoint .getAccountId () )
8384 .getSingleResultOrNull ()
8485 .invoke ( result -> {
8586 context .assertNotNull ( result );
86- context .assertTrue ( Hibernate .isInitialized ( result .webhook ) );
87- context .assertEquals ( endpoint .id , result .id );
88- context .assertEquals ( webhook .id , result .webhook . id );
87+ context .assertTrue ( Hibernate .isInitialized ( result .getWebhook () ) );
88+ context .assertEquals ( endpoint .getId () , result .getId () );
89+ context .assertEquals ( webhook .getId () , result .getWebhook (). getId () );
8990 } ) )
9091 );
9192 }
@@ -96,13 +97,36 @@ public static class Endpoint {
9697
9798 @ Id
9899 @ GeneratedValue
99- public Long id ;
100+ private Long id ;
100101
101102 @ OneToOne (mappedBy = "endpoint" , fetch = FetchType .LAZY , cascade = CascadeType .ALL )
102- public EndpointWebhook webhook ;
103+ private EndpointWebhook webhook ;
104+
105+ private String accountId ;
106+
107+ public Long getId () {
108+ return id ;
109+ }
110+
111+ public void setId (Long id ) {
112+ this .id = id ;
113+ }
114+
115+ public EndpointWebhook getWebhook () {
116+ return webhook ;
117+ }
118+
119+ public void setWebhook (EndpointWebhook webhook ) {
120+ this .webhook = webhook ;
121+ }
103122
104- public String accountId ;
123+ public String getAccountId () {
124+ return accountId ;
125+ }
105126
127+ public void setAccountId (String accountId ) {
128+ this .accountId = accountId ;
129+ }
106130
107131 @ Override
108132 public String toString () {
@@ -121,11 +145,27 @@ public static class EndpointWebhook {
121145
122146 @ Id
123147 @ GeneratedValue
124- public Long id ;
148+ private Long id ;
125149
126150 @ OneToOne (fetch = FetchType .LAZY )
127151 @ JoinColumn (name = "endpoint_id" )
128- public Endpoint endpoint ;
152+ private Endpoint endpoint ;
153+
154+ public Long getId () {
155+ return id ;
156+ }
157+
158+ public void setId (Long id ) {
159+ this .id = id ;
160+ }
161+
162+ public Endpoint getEndpoint () {
163+ return endpoint ;
164+ }
165+
166+ public void setEndpoint (Endpoint endpoint ) {
167+ this .endpoint = endpoint ;
168+ }
129169
130170 @ Override
131171 public String toString () {
0 commit comments