Closed basanta4043 closed 1 year ago
Hi, can you provide an example app/test? I couldn't reproduce with this sample entity
import io.micronaut.data.annotation.Id;
import io.micronaut.data.jdbc.annotation.ColumnTransformer;
import javax.persistence.Entity;
@Entity
public class Sample {
@Id
private Long id;
@ColumnTransformer(read = "pgp_sym_decrypt(@.card_no, '123@Test')")
private String cardNo;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCardNo() {
return cardNo;
}
public void setCardNo(String cardNo) {
this.cardNo = cardNo;
}
}
and query findById gives SQL like this
SELECT sample_."id",pgp_sym_decrypt(sample_.card_no, \'123@Test\') AS card_no FROM "sample" sample_ WHERE (sample_."id" = ?)
So don't see @
in transform function gets translated to entity (alias) and would be good if you can provide example and results you are getting. Also, what version are you using? I tried this with latest micronaut-data 3.9.6
Hello This is my entity class:
import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Nullable; import io.micronaut.data.annotation.GeneratedValue; import io.micronaut.data.annotation.Id; import io.micronaut.data.annotation.MappedEntity; import io.micronaut.data.jdbc.annotation.ColumnTransformer; import io.soabase.recordbuilder.core.RecordBuilder; import jakarta.persistence.Column; import jakarta.persistence.Table;
@Introspected @RecordBuilder @Table(schema = "public") @MappedEntity("agent_modes") public record AgentModeEntity( @Id @GeneratedValue(ref = "hibernate_sequence", value = GeneratedValue.Type.SEQUENCE) long id, boolean isActive, @Nullable String agentCode, @Nullable boolean allowForAllCustomer, @Nullable boolean allowOtpRequest, @Nullable boolean allowRealtimeChequePayment, @Nullable boolean allowSameBranchOnly, @Nullable String createdBy, @Nullable String createdOn, @Nullable String modifiedBy, @Nullable String modifiedOn, @Nullable String deletedBy, @Nullable String deletedOn, @Nullable String approvedBy, @Nullable String approvedOn, @Nullable String bankCode, @Nullable String cardNoOld, @Nullable String cbsCustomerId, @Nullable String contactPerson, @Nullable Long customerFilterId, @Nullable String name, @Nullable String addressOne, @Nullable String addressTwo, @Nullable String mobileNumber, @Nullable String notes, @Nullable String terminalId, @Nullable Long refId, @Nullable String rejectReason, @Nullable String status, @Nullable Long branchId, @Nullable Long posId, @Nullable Long bankSchemeId, @Nullable Long billerSchemeId, @Nullable Long merchantSchemeId, @Nullable Long mobileBankingSchemeId, @Nullable Long nonBlbCustomerSchemeId, @Nullable Long remittanceSchemeId, @Nullable Long walletSchemeId, @Nullable Long agentCommissionId, @Nullable Long bankUserId, @Nullable Long projectId, @Nullable @Column(columnDefinition = "text") String remittanceCredentials, @Nullable String nrbAgentCode, @Column(columnDefinition = "bytea") @ColumnTransformer(read = "gen_decrypt_card(card_no, '123@nibl')", write = "gen_encrypt_card(card_no, '123@nibl')") String cardNo ) { }
while fetching data I got
select ............,gen_decrypt_card(card_no,'123agent_modeentity.ibl'),..
instead of gen_decrypt_card(card_no,'123@nibl')
I am using micronaut -data 2.4.3
Hello This is my entity class:
import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Nullable; import io.micronaut.data.annotation.GeneratedValue; import io.micronaut.data.annotation.Id; import io.micronaut.data.annotation.MappedEntity; import io.micronaut.data.jdbc.annotation.ColumnTransformer; import io.soabase.recordbuilder.core.RecordBuilder; import jakarta.persistence.Column; import jakarta.persistence.Table;
@introspected https://github.com/introspected @RecordBuilder @table https://github.com/table(schema = "public") @MappedEntity("agent_modes") public record AgentModeEntity( @id https://github.com/id @GeneratedValue(ref = "hibernate_sequence", value = GeneratedValue.Type.SEQUENCE) long id, boolean isActive, @nullable https://github.com/nullable String agentCode, @nullable https://github.com/nullable boolean allowForAllCustomer, @nullable https://github.com/nullable boolean allowOtpRequest, @nullable https://github.com/nullable boolean allowRealtimeChequePayment, @nullable https://github.com/nullable boolean allowSameBranchOnly, @nullable https://github.com/nullable String createdBy, @nullable https://github.com/nullable String createdOn, @nullable https://github.com/nullable String modifiedBy, @nullable https://github.com/nullable String modifiedOn, @nullable https://github.com/nullable String deletedBy, @nullable https://github.com/nullable String deletedOn, @nullable https://github.com/nullable String approvedBy, @nullable https://github.com/nullable String approvedOn, @nullable https://github.com/nullable String bankCode, @nullable https://github.com/nullable String cardNoOld, @nullable https://github.com/nullable String cbsCustomerId, @nullable https://github.com/nullable String contactPerson, @nullable https://github.com/nullable Long customerFilterId, @nullable https://github.com/nullable String name, @nullable https://github.com/nullable String addressOne, @nullable https://github.com/nullable String addressTwo, @nullable https://github.com/nullable String mobileNumber, @nullable https://github.com/nullable String notes, @nullable https://github.com/nullable String terminalId, @nullable https://github.com/nullable Long refId, @nullable https://github.com/nullable String rejectReason, @nullable https://github.com/nullable String status, @nullable https://github.com/nullable Long branchId, @nullable https://github.com/nullable Long posId, @nullable https://github.com/nullable Long bankSchemeId, @nullable https://github.com/nullable Long billerSchemeId, @nullable https://github.com/nullable Long merchantSchemeId, @nullable https://github.com/nullable Long mobileBankingSchemeId, @nullable https://github.com/nullable Long nonBlbCustomerSchemeId, @nullable https://github.com/nullable Long remittanceSchemeId, @nullable https://github.com/nullable Long walletSchemeId, @nullable https://github.com/nullable Long agentCommissionId, @nullable https://github.com/nullable Long bankUserId, @nullable https://github.com/nullable Long projectId, @nullable https://github.com/nullable @column https://github.com/column(columnDefinition = "text") String remittanceCredentials, @nullable https://github.com/nullable String nrbAgentCode, @column https://github.com/column(columnDefinition = "bytea") @ColumnTransformer(read = "gen_decrypt_card(card_no, @.')", write = "gen_encrypt_card(card_no, @.')") String cardNo ) { }
while fetching data I got
select ............,gen_decrypt_card(card_no,'123agent_modeentity.ibl'),..
instead of @.***')
i am using micronaut data 24.3
Message ID: <micronaut-projects/micronaut-data/issues/2037/1437995248@ github.com>
Can you try latest micronaut version, seems like it's not happening there (unless some of your annotations like RecordBuilder
are making difference which shouldn't be).
There has been issue similar to this earlier https://github.com/micronaut-projects/micronaut-data/issues/1294 (fixed by PR https://github.com/micronaut-projects/micronaut-data/pull/1298) and it was said won't be fixed back in 2.5.x
The issue was reported in 2.4.3 micronaut-data version and has been fixed in newer versions.
Issue description
I have used @ColumnTransfermer in my project like : @ColumnTransformer(read = "pgp_sym_decrypt(card_no, '123@Test')")
the issue is @ in the key is a query alias placeholder and is converted to an entity name. How could I escape the '@' character in my key?