-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-12997 Specific exception thrown when trying to @JoinFormula along with @OneToMany #3363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+153
−1
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
...e-core/src/test/java/org/hibernate/test/annotations/formula/JoinFormulaWithOneToMany.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| package org.hibernate.test.annotations.formula; | ||
|
|
||
| import org.hibernate.annotations.JoinFormula; | ||
| import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; | ||
| import org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor; | ||
| import org.hibernate.testing.FailureExpected; | ||
| import org.hibernate.testing.TestForIssue; | ||
| import org.hibernate.testing.junit4.BaseUnitTestCase; | ||
| import org.junit.Test; | ||
|
|
||
| import javax.persistence.Entity; | ||
| import javax.persistence.GeneratedValue; | ||
| import javax.persistence.GenerationType; | ||
| import javax.persistence.Id; | ||
| import javax.persistence.ManyToOne; | ||
| import javax.persistence.OneToMany; | ||
| import javax.persistence.SharedCacheMode; | ||
| import javax.persistence.Table; | ||
| import javax.persistence.ValidationMode; | ||
| import javax.persistence.spi.ClassTransformer; | ||
| import javax.persistence.spi.PersistenceUnitInfo; | ||
| import javax.persistence.spi.PersistenceUnitTransactionType; | ||
| import javax.sql.DataSource; | ||
| import java.net.URL; | ||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Properties; | ||
| import java.util.Set; | ||
|
|
||
| public class JoinFormulaWithOneToMany extends BaseUnitTestCase { | ||
|
|
||
| @Test | ||
| @TestForIssue(jiraKey = "HHH-12997") | ||
| @FailureExpected(jiraKey = "HHH-12997") | ||
| public void testJoinFormulaWithOneToMany() { | ||
|
|
||
| PersistenceUnitInfo info = new PersistenceUnitInfo() { | ||
| @Override | ||
| public String getPersistenceUnitName() { | ||
| return "test"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getPersistenceProviderClassName() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public PersistenceUnitTransactionType getTransactionType() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public DataSource getJtaDataSource() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public DataSource getNonJtaDataSource() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public List<String> getMappingFileNames() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public List<URL> getJarFileUrls() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public URL getPersistenceUnitRootUrl() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public List<String> getManagedClassNames() { | ||
| return Arrays.asList(Parent.class.getName(), Child.class.getName()); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean excludeUnlistedClasses() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public SharedCacheMode getSharedCacheMode() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public ValidationMode getValidationMode() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Properties getProperties() { | ||
| return new Properties(); | ||
| } | ||
|
|
||
| @Override | ||
| public String getPersistenceXMLSchemaVersion() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public ClassLoader getClassLoader() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public void addTransformer(ClassTransformer transformer) { | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public ClassLoader getNewTempClassLoader() { | ||
| return null; | ||
| } | ||
|
|
||
| }; | ||
|
|
||
| new EntityManagerFactoryBuilderImpl(new PersistenceUnitInfoDescriptor(info), | ||
| Collections.singletonMap("hibernate.dialect", "org.hibernate.dialect.H2Dialect")).build(); | ||
|
|
||
| } | ||
|
|
||
| @Entity @Table(name = "child") class Child { | ||
|
|
||
| @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; | ||
|
|
||
| @ManyToOne() @JoinFormula(value = "(SELECT * FROM child)") private Parent parent; | ||
|
|
||
| } | ||
|
|
||
| @Entity @Table(name = "parent") class Parent { | ||
|
|
||
| @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; | ||
|
|
||
| @OneToMany(mappedBy = "parent") private Set<Child> childs; | ||
|
|
||
| } | ||
|
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.