Skip to content

Commit

Permalink
[Hibernate 6]: Fixed the generated bool value + add test
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillKurdyukov committed May 17, 2024
1 parent 9376490 commit 3d899d8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ public class Employee {
@Column(name = "limit_domain_password")
private LocalDateTime limitDomainPassword;

@Column
private byte[] bytes;

@Column
private Enum anEnum;

@Enumerated(EnumType.STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,9 @@ void integrationTypesTest() {
employee.setActive(false);
inTransaction(session -> session.merge(employee));
inTransaction(session -> assertEquals(employee, session.find(Employee.class, employee.getId())));

inTransaction(session -> assertEquals(employee, session
.createQuery("FROM Employee e WHERE e.isActive = false", Employee.class)
.getSingleResult()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.hibernate.mapping.Index;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.spi.SqlAppender;
import org.hibernate.tool.schema.spi.Exporter;
import org.hibernate.type.BasicType;
import static org.hibernate.type.SqlTypes.BIGINT;
Expand Down Expand Up @@ -182,6 +183,11 @@ public boolean supportsExistsInSelect() {
return false;
}

@Override
public void appendBooleanValueString(SqlAppender appender, boolean bool) {
appender.append(toBooleanValueString(bool));
}

@Override
public String toBooleanValueString(boolean bool) {
return String.valueOf(bool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ public class Employee {
@Column(name = "limit_domain_password")
private LocalDateTime limitDomainPassword;

@Column
private byte[] bytes;

@Column
private Enum anEnum;

@Enumerated(EnumType.STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,9 @@ void integrationTypesTest() {
employee.setActive(false);
inTransaction(session -> session.merge(employee));
inTransaction(session -> assertEquals(employee, session.find(Employee.class, employee.getId())));

inTransaction(session -> assertEquals(employee, session
.createQuery("FROM Employee e WHERE e.isActive = false", Employee.class)
.getSingleResult()));
}
}

0 comments on commit 3d899d8

Please sign in to comment.