Skip to content

Commit

Permalink
HBX-2390: Create a JBoss Tools adaptation layer in Hibernate Tools
Browse files Browse the repository at this point in the history
  - Add new test case 'org.hibernate.tool.orm.jbt.wrp.QueryWrapperFactoryTest#testGetReturnTypes()'
  - Add new interface method 'org.hibernate.tool.orm.jbt.wrp.QueryWrapperFactory.QueryExtension#getReturnTypes()'

Signed-off-by: Koen Aers <[email protected]>
  • Loading branch information
koentsje committed Jun 27, 2023
1 parent acaa0ff commit 312176e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

import org.hibernate.query.Query;
import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.type.Type;

public class QueryWrapperFactory {

@SuppressWarnings({ "unchecked", "rawtypes" })
public static QueryWrapper<?> createQueryWrapper(Query<?> query) {
return (QueryWrapper<?>)Proxy.newProxyInstance(
QueryWrapperFactory.class.getClassLoader(),
Expand All @@ -22,9 +24,8 @@ static interface QueryExtension<T> extends Wrapper {
void setParameterList(String name, List<Object> list, Object anything);
void setParameter(String string, Object value, Object anything);
void setParameter(int i, Object value, Object anything);
default String[] getReturnAliases() {
return new String[0];
}
default String[] getReturnAliases() { return new String[0]; }
default Type[] getReturnTypes() { return new Type[0]; }
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.hibernate.tool.orm.jbt.util.NativeConfiguration;
import org.hibernate.tool.orm.jbt.wrp.QueryWrapperFactory.QueryWrapper;
import org.hibernate.tool.orm.jbt.wrp.SessionWrapperFactory.SessionWrapper;
import org.hibernate.type.Type;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -163,6 +164,13 @@ public void testGetReturnAliases() {
assertEquals(0, aliases.length);
}

@Test
public void testGetReturnTypes() {
Type[] returnTypes = simpleQueryWrapper.getReturnTypes();
assertNotNull(returnTypes);
assertEquals(0, returnTypes.length);
}

private void createDatabase() throws Exception {
connection = DriverManager.getConnection("jdbc:h2:mem:test");
statement = connection.createStatement();
Expand Down

0 comments on commit 312176e

Please sign in to comment.