HHH-18920 Test case - Jakarta Data repository with query selecting enum column
This commit is contained in:
parent
928799d5bd
commit
54781895db
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.data.selectenumproperty;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Topic {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer topicId;
|
||||
|
||||
private TopicStatus topicStatus;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.data.selectenumproperty;
|
||||
|
||||
|
||||
record TopicData(Integer topicId, TopicStatus topicStatus) {
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.data.selectenumproperty;
|
||||
|
||||
import jakarta.data.repository.DataRepository;
|
||||
import jakarta.data.repository.Query;
|
||||
import jakarta.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface TopicRepository extends DataRepository<Topic, Integer> {
|
||||
|
||||
@Query("select topicId, topicStatus from Topic")
|
||||
List<TopicData> getTopicData();
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.data.selectenumproperty;
|
||||
|
||||
public enum TopicStatus {
|
||||
TOPIC_UNLOCKED( 0 ),
|
||||
TOPIC_LOCKED( 1 );
|
||||
|
||||
private final int topicStatus;
|
||||
|
||||
TopicStatus(final int topicStatus) {
|
||||
this.topicStatus = topicStatus;
|
||||
}
|
||||
|
||||
public int topicStatus() {
|
||||
return topicStatus;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.data.selectenumproperty;
|
||||
|
||||
import org.hibernate.processor.test.util.CompilationTest;
|
||||
import org.hibernate.processor.test.util.WithClasses;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
|
||||
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;
|
||||
|
||||
public class TopicTypeEnumTest extends CompilationTest {
|
||||
@Test
|
||||
@WithClasses({Topic.class, TopicRepository.class})
|
||||
public void test() {
|
||||
System.out.println( getMetaModelSourceAsString( Topic.class ) );
|
||||
System.out.println( getMetaModelSourceAsString( Topic.class, true ) );
|
||||
System.out.println( getMetaModelSourceAsString( TopicRepository.class ) );
|
||||
assertMetamodelClassGeneratedFor( Topic.class, true );
|
||||
assertMetamodelClassGeneratedFor( Topic.class );
|
||||
assertMetamodelClassGeneratedFor( TopicRepository.class );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue