Comments (6)
Hey there. The fix should be pretty simple, so if you want to take a stab at trying to provide a PR for this, I'd be very grateful. In the meantime, you should be able to register a custom BooleanBasicUserType
with a custom conversion strategy via com.blazebit.persistence.view.spi.EntityViewConfiguration#registerBasicUserType
.
from blaze-persistence.
DripCampaignEntity:
@Table(name = "drip_campaign")
@Entity(name = "DripCampaign" )
@Audited
@Getter
@Setter
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
@Where(clause="deleted_at is null")
@NamedEntityGraph(name = DripCampaignEntity.DRIP_CAMPAIGN_ENTITY_GRAPH_ALL,
attributeNodes = {
@NamedAttributeNode(value = "steps", subgraph = "steps.template"),
@NamedAttributeNode(value = "campaignSubscriptionTriggers"),
},subgraphs = {
@NamedSubgraph(name = "steps.template",
attributeNodes =
{@NamedAttributeNode("template")})
})
public class DripCampaignEntity extends AbstractAuditingResource<Long> {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@Size(max = 1024)
private String name;
private Instant preferredSendDate;
private Instant preferredSendTime;
@Column(nullable = false, columnDefinition = "boolean default false")
@Builder.Default
private boolean enabled = false;
@Column(updatable = false,insertable = false)
private Instant lastSentAt;
@Column(name="steps_count", nullable = false, columnDefinition = "int default 0")
private int stepsCount = 0;
@OneToMany(mappedBy = "dripCampaign", fetch = FetchType.LAZY)
@Where(clause="deleted_at is null")
@OrderBy("stepIndex")
@Builder.Default
@Fetch(FetchMode.SUBSELECT)
private List<DripCampaignStepEntity> steps = new ArrayList<>();
@NotAudited
@OneToMany(fetch = FetchType.LAZY,mappedBy = "dripCampaign",orphanRemoval = true,cascade={CascadeType.REMOVE})
private Set<DripTriggerEntity> campaignSubscriptionTriggers = new HashSet<>();
/*Don't use directly*/
@NotAudited
@OneToMany(mappedBy = "dripCampaign", fetch = FetchType.LAZY)
@Builder.Default
private Set<DripCampaignSubscriberEntity> subscribedUsers = new HashSet<>();
@Column(updatable = false)
private Instant deletedAt;
public final static String DRIP_CAMPAIGN_ENTITY_GRAPH_ALL = "drip_campaign.all";
@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
if (thisEffectiveClass != oEffectiveClass) return false;
DripCampaignEntity that = (DripCampaignEntity) o;
return getId() != null && Objects.equals(getId(), that.getId());
}
@Override
public final int hashCode() {
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
}
}
DripTriggerEntity:
@Table(name = "drip_trigger")
@Entity(name="DripTrigger")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "type",discriminatorType=DiscriminatorType.STRING)
@Getter
@Setter
public abstract class DripTriggerEntity extends AbstractAuditingResource<Long> {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
protected Long id;
/*
* The variable determines whether the logic should be triggered for existing data (true)
* or only for new ones (false).
*/
@Column(nullable = false, columnDefinition = "boolean default false")
protected boolean retrospectionEnabled = false;
@Builder.Default
@Column(nullable = false, columnDefinition = "boolean default false")
protected boolean enabled = false;
@Enumerated(EnumType.STRING)
@Getter(AccessLevel.NONE)
@Column(name="type", insertable = false, updatable = false)
protected DripTriggerType type;
@ManyToOne(fetch = FetchType.LAZY,optional = false)
@JoinColumn(name = "drip_campaign", updatable = false)
protected DripCampaignEntity dripCampaign;
@Transient
public DripTriggerType getTriggerType() {
var discriminatorAnnotation = this.getClass().getAnnotation(DiscriminatorValue.class);
if(discriminatorAnnotation == null) {
throw new PublicCrmRuntimeException("Cannot get discriminator value of Base Entity class");
}
return DripTriggerType.valueOf(discriminatorAnnotation.value());
}
@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
if (thisEffectiveClass != oEffectiveClass) return false;
DripTriggerEntity that = (DripTriggerEntity) o;
return getId() != null && Objects.equals(getId(), that.getId());
}
@Override
public final int hashCode() {
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
}
}
from blaze-persistence.
from blaze-persistence.
MultisetTupleTransformer received "1"
from blaze-persistence.
I think that problem is here:
BooleanBasicUserType.fromString("1") returns false
from blaze-persistence.
As i understand converter now supports only "true", "false" values, and doesn't support 1 or 0, but it takes 1 or 0 if we use multiset.
from blaze-persistence.
Related Issues (20)
- Re-using ObjectMapper from spring-boot for EntityViewAwareMappingJackson2HttpMessageConverter leads to issues HOT 3
- Allow multiple named subqueries for @MappingSubquery
- Optimization of logging in the AnnotationUtils Utility Class HOT 1
- FR: Support field-EntityView deserializatin for DTOs which are non-entity views
- Expose EntityViewAwareMappingJackson2HttpMessageConverter as a Bean to support re-usage for http-clients
- Property naming strategy for Jackson integration does not work HOT 3
- How to ignore a certain `Getter` in EntityView? HOT 1
- Query DSL with blaze-persistence is generating an extra joining HOT 6
- SubviewAttributeFlusher always cascade deletes
- Exception thrown when using LocalDate in an EntityView being fetched using the Multiset strategy
- Startup error with Spring Boot 3.3.0 and Blaze Persistence Repositories HOT 5
- "No viable alternative at input" error near 'entity_function'
- Exception thrown when using subQuery + pagedList
- Fetching of MULTISET attribute not working HOT 3
- Question. Can i use fields mapped as @Convert in multiset mode? HOT 1
- Cannot invoke "EntityType.getName()" because the return value of "JoinNode.getTreatType()" is null HOT 1
- Pagination in queries that join on an @OneToMany or @ManyToMany attribute return duplicate results HOT 1
- IS NOT NULL not possible in correlationExpression HOT 3
- Exclude Certain Attributes in View HOT 2
- Simple query with an EXISTS clause and pagination adds an unnecessary inner ID query HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blaze-persistence.