Siena / Play / GAE incorrectly parses a logical field: 0 = true

It's hard for me to work with booleans in Siena 2.0.7 and Play 1.2.4.

In the constructor of my class, I set the boolean value to FALSE. Then I save the object. In the data warehouse viewer, I see that the logical field is saved as 0.

When I retrieve this row from the database, the logical field is parsed as TRUE. I'm lost, hope you can help!

Grade:

@Entity public class CMessage extends EnhancedModel { public CMessage() { this.isProcessed = false; } public CMessage(String bridgeId) { this.bridgeId = bridgeId; // set createdDate & expireDate this.createdDate = new Date(); this.isProcessed = false; } @Id(Generator.AUTO_INCREMENT) public Long id; @NotNull public String bridgeId; @NotNull @DateTime public Date createdDate; @NotNull public boolean isProcessed; } 

Test:

  CMessage msg = new models.CMessage("bridge"); Logger.info("saved isProcessed = %s", msg.isProcessed); // always gives false msg.save(); Logger.info("saved isProcessed = %s", msg.isProcessed); // always gives false CMessage get = (CMessage) CMessage.findAll().get(0); Logger.info("got isProcessed = %s", get.isProcessed); // always gives true assertEquals(false, get.isProcessed); 

Note: I did not test GAE myself, only on my dev machine. Maybe gae datastore is doing everything right ...

+4
source share
2 answers

This seems to be a bug in the current version of Siena: https://github.com/mandubian/siena/pull/18

+4
source

It is rather strange that you get True ...
Could you try with a boolean and not a boolean to see if you have the same behavior? Thanks

+1
source

Source: https://habr.com/ru/post/1403436/


All Articles