J
John Miller
Guest
I don’t believe it would make a difference in performance if the values were part of the Entity or if they are hard coded. I was just trying to hit home the idea of the one-to-one mapping of an Entity to a database record. To your last question, you will always see a SQL statement for each instance of an Entity in memory. But as stated before, the updates are added to a PreparedStatement Batch, which is optimal. Example: 3 Person Entities in memory Person Id = 1 Name = Tom Validated = true Person Id = 2 Name = *** Validated = false Person Id = 3 Name = Harry Validated = true ADC_WRITE_DEF -> SQL UPDATE Person SET validated={Person.validated}, Person.updated_by='John Wick', Person.updated_at=now() where Person.in IN ({Person.id}) This produces 3 SQL statements: UPDATE Person SET validated=true, Person.updated_by='John Wick', Person.updated_at=now() where Person.in IN (1) UPDATE Person SET validated=false, Person.updated_by='John Wick', Person.updated_at=now() where Person.in IN (2) UPDATE Person SET validated=true, Person.updated_by='John Wick', Person.updated_at=now() where Person.in IN (3) Because Person.id = 2 has a Validated = false, which is different than Person.id = 1 and Person.id = 3, these SQL statements can’t be combined. UPDATE Person SET validated=true , Person.updated_by='John Wick', Person.updated_at=now() where Person.in IN (1, 2, 3) is incorrect. For me, it is easier to understand that there is a discrete SQL statement for each Entity. This reduces complexity and hopefully it reduces confusion in creating a valid ADC_WRITE_DEF -> SQL statement. I hope this helps. -John
Continue reading...
Continue reading...