gorm-hibernate5 icon indicating copy to clipboard operation
gorm-hibernate5 copied to clipboard

Derived fields with formula not working

Open cgoIT opened this issue 5 years ago • 3 comments

Steps to Reproduce

I've created a simple demo app which shows my problem. I tried to use a derived field in one of my domain classes using formula in mapping closure. I want to use a subselect to a view. I cannot use some kind of size() method oder something like this in my real app for some special reasons.

I thought I don't have to use transients for this field. But if I omit this, gorm creates a column in my table for property projectCount.

Expected Behaviour

I just want grails/gorm to use my sql statement under formula to be executed if i read the property projectCount of my domain class Person.

Actual Behaviour

The sql statement is never executed and the value of the property projectCount is always 0.

Environment Information

Operating System: Mac OSX 10.14.5 GORM Version: 6.1.11.RELEASE Grails Version (if using Grails): 3.3.10 JDK Version: OpenJDK 64-Bit Server VM (Zulu 8.38.0.13-CA-macosx) (build 25.212-b04, mixed mode)

Example Application

An small example project could be found at https://github.com/cgoIT/grails-formula-bug

cgoIT avatar Jun 24 '19 08:06 cgoIT

Thanks for the PR, we will take a look

graemerocher avatar Jun 24 '19 10:06 graemerocher

+1 can reproduce in my project. will there be any action on this?

thysce avatar Jun 24 '20 08:06 thysce

I ran into the same issue.

virtualdogbert avatar Jul 14 '20 18:07 virtualdogbert