-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1294] Fix various issues with type resolving paths that match entit…
…y names
- Loading branch information
Showing
7 changed files
with
158 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
62 changes: 62 additions & 0 deletions
62
core/testsuite/src/main/java/com/blazebit/persistence/testsuite/entity/DocumentHolder.java
This file contains 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,62 @@ | ||
/* | ||
* Copyright 2014 - 2021 Blazebit. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.blazebit.persistence.testsuite.entity; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.OneToOne; | ||
import java.io.Serializable; | ||
|
||
/** | ||
* | ||
* @author Christian Beikov | ||
* @since 1.6.0 | ||
*/ | ||
@Entity | ||
public class DocumentHolder implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Id | ||
private Long id; | ||
@OneToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "document_id") | ||
// CHECKSTYLE:OFF: MemberName | ||
private Document Document; | ||
// CHECKSTYLE:ON: MemberName | ||
|
||
public DocumentHolder() { | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public Document getDocument() { | ||
return Document; | ||
} | ||
|
||
public void setDocument(Document document) { | ||
this.Document = document; | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
70 changes: 70 additions & 0 deletions
70
...st/java/com/blazebit/persistence/view/testsuite/basic/AttributeMatchesEntityNameTest.java
This file contains 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,70 @@ | ||
/* | ||
* Copyright 2014 - 2021 Blazebit. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.blazebit.persistence.view.testsuite.basic; | ||
|
||
import com.blazebit.persistence.testsuite.entity.Document; | ||
import com.blazebit.persistence.testsuite.entity.DocumentHolder; | ||
import com.blazebit.persistence.view.EntityView; | ||
import com.blazebit.persistence.view.EntityViewManager; | ||
import com.blazebit.persistence.view.IdMapping; | ||
import com.blazebit.persistence.view.Mapping; | ||
import com.blazebit.persistence.view.testsuite.AbstractEntityViewTest; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* | ||
* @author Christian Beikov | ||
* @since 1.6.0 | ||
*/ | ||
public class AttributeMatchesEntityNameTest extends AbstractEntityViewTest { | ||
|
||
protected EntityViewManager evm; | ||
|
||
@Override | ||
protected Class<?>[] getEntityClasses() { | ||
return concat(super.getEntityClasses(), DocumentHolder.class); | ||
} | ||
|
||
@Before | ||
public void initEvm() { | ||
evm = build( | ||
DocumentHolderView.class, | ||
DocumentIdView.class | ||
); | ||
} | ||
|
||
@EntityView(DocumentHolder.class) | ||
public interface DocumentHolderView { | ||
@IdMapping | ||
Long getId(); | ||
@Mapping("Document") | ||
DocumentIdView getDocument(); | ||
} | ||
|
||
@EntityView(Document.class) | ||
public interface DocumentIdView { | ||
@IdMapping | ||
Long getId(); | ||
} | ||
|
||
// Test for https://github.com/Blazebit/blaze-persistence/issues/1294 | ||
@Test | ||
public void testFetch() { | ||
evm.find(em, DocumentHolderView.class, 1L); | ||
} | ||
} |