Skip to content
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

Reproducer for vladmihalcea/hibernate-types#27 #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
@@ -0,0 +1,58 @@
package com.vladmihalcea.hibernate.type.json;

import com.vladmihalcea.hibernate.type.model.BaseEntity;
import com.vladmihalcea.hibernate.type.model.Location;
import com.vladmihalcea.hibernate.type.util.AbstractPostgreSQLIntegrationTest;
import org.hibernate.annotations.Type;
import org.junit.Test;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;

public class PostgreSQLJsonBinaryTypeUnionTest extends AbstractPostgreSQLIntegrationTest {

@Override
protected Class<?>[] entities() {
return new Class[] {
Base.class,
Sub1.class,
Sub2.class
};
}

@Test
public void testUnionFetch() {
doInJPA(em -> {
em.createQuery("SELECT a FROM Base a", Base.class).getResultList();
});
}

@Entity(name = "Base")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public static abstract class Base extends BaseEntity {

}

@Entity
public static abstract class Sub1 extends Base {

@Type(type = "jsonb")
@Column(columnDefinition = "jsonb")
private Location location;

public Location getLocation() {
return location;
}

public void setLocation(Location location) {
this.location = location;
}

}

@Entity
public static abstract class Sub2 extends Base {}

}