Skip to content

Commit

Permalink
Allow OneToOne to map to ManyToOne (#3569)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbygrave authored Feb 19, 2025
1 parent 8dd438b commit 40637bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1002,11 +1002,8 @@ private DeployBeanPropertyAssocOne<?> mappedOneToOne(DeployBeanPropertyAssocOne<
if (!(mappedProp instanceof DeployBeanPropertyAssocOne<?>)) {
throw new PersistenceException("Error on " + prop + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a OneToOne?");
}
DeployBeanPropertyAssocOne<?> mappedAssocOne = (DeployBeanPropertyAssocOne<?>) mappedProp;
if (!mappedAssocOne.isOneToOne()) {
throw new PersistenceException("Error on " + prop + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a OneToOne?");
}
return mappedAssocOne;
// this is allowed to be a OneToOne or ManyToOne
return (DeployBeanPropertyAssocOne<?>) mappedProp;
}

private void checkUniDirectionalPrimaryKeyJoin(DeployBeanPropertyAssocOne<?> prop) {
Expand Down
8 changes: 3 additions & 5 deletions ebean-test/src/test/java/org/tests/model/basic/OEngine.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.tests.model.basic;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Version;
import jakarta.persistence.*;

import java.io.Serializable;
import java.util.UUID;

Expand All @@ -20,7 +18,7 @@ public class OEngine implements Serializable {
@Version
private Integer version;

@OneToOne
@ManyToOne
private OCar car;

public OEngine() {
Expand Down

0 comments on commit 40637bd

Please sign in to comment.