Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ private static Collection<AnnotatedFieldDescription> collectInheritPersistentFie
}
TypeDefinition managedCtSuperclass = managedCtClass.getSuperClass();

if ( enhancementContext.isEntityClass( managedCtSuperclass.asErasure() ) ) {
// If managedCtSuperclass is null, managedCtClass can be either interface or module-info.
// Interfaces are already filtered-out, and module-info does not have any fields to enhance
// so we can safely return empty list.
if ( managedCtSuperclass == null || enhancementContext.isEntityClass( managedCtSuperclass.asErasure() ) ) {
return Collections.emptyList();
}
else if ( !enhancementContext.isMappedSuperclassClass( managedCtSuperclass.asErasure() ) ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.tooling.gradle;

import java.nio.file.Path;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;


/**
* Basic functional tests
*
* @author Steve Ebersole
*/
class ModuleInfoProjectTests extends TestsBase {

@Override
protected String getProjectName() {
return "simple-moduleinfo";
}

@Override
protected String getSourceSetName() {
return "main";
}

@Override
protected String getLanguageName() {
return "java";
}

@Override
protected String getCompileTaskName() {
return "compileJava";
}

@Test
@Override
public void testEnhancement(@TempDir Path projectDir) throws Exception {
super.testEnhancement( projectDir );
}

@Test
@Override
public void testEnhancementUpToDate(@TempDir Path projectDir) throws Exception {
super.testEnhancementUpToDate( projectDir );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/

plugins {
id 'java'
id 'org.hibernate.orm'
}

repositories {
mavenCentral()

maven {
name 'jboss-snapshots-repository'
url 'https://repository.jboss.org/nexus/content/repositories/snapshots'
}
}

dependencies {
// NOTE : The version used here is irrelevant in terms of testing the plugin.
// We just need a resolvable version
implementation 'org.hibernate.orm:hibernate-core:6.1.0.Final'
implementation 'jakarta.annotation:jakarta.annotation-api:2.1.1'
}

hibernate {
useSameVersion = false
enhancement {
enableLazyInitialization.set(true)
lazyInitialization = true

enableDirtyTracking.set(true)
dirtyTracking = true

enableExtendedEnhancement.set(true)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
import jakarta.persistence.Embeddable;

@Embeddable
public class TheEmbeddable {
private String valueOne;
private String valueTwo;

public String getValueOne() {
return valueOne;
}

public void setValueOne(String valueOne) {
this.valueOne = valueOne;
}

public String getValueTwo() {
return valueTwo;
}

public void setValueTwo(String valueTwo) {
this.valueTwo = valueTwo;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;

import org.hibernate.annotations.BatchSize;

import java.util.Set;

@Entity
@BatchSize( size = 20 )
public class TheEntity {
@Id
private Integer id;
private String name;

@Embedded
private TheEmbeddable theEmbeddable;

@ManyToOne
@JoinColumn
private TheEntity theManyToOne;

@OneToMany( mappedBy = "theManyToOne" )
private Set<TheEntity> theOneToMany;

@ElementCollection
@JoinColumn( name = "owner_id" )
private Set<TheEmbeddable> theEmbeddableCollection;


public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public TheEmbeddable getTheEmbeddable() {
return theEmbeddable;
}

public void setTheEmbeddable(TheEmbeddable theEmbeddable) {
this.theEmbeddable = theEmbeddable;
}

public TheEntity getTheManyToOne() {
return theManyToOne;
}

public void setTheManyToOne(TheEntity theManyToOne) {
this.theManyToOne = theManyToOne;
}

public Set<TheEntity> getTheOneToMany() {
return theOneToMany;
}

public void setTheOneToMany(Set<TheEntity> theOneToMany) {
this.theOneToMany = theOneToMany;
}

public Set<TheEmbeddable> getTheEmbeddableCollection() {
return theEmbeddableCollection;
}

public void setTheEmbeddableCollection(Set<TheEmbeddable> theEmbeddableCollection) {
this.theEmbeddableCollection = theEmbeddableCollection;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module test {
requires org.hibernate.orm.core;
requires jakarta.persistence;
requires jakarta.annotation;
}