@MetaProperty from cuba to Jmix 2.2.0

Hi, I am currently porting over my cuba code to Jmix 2.x version , and I am currently stuck at this code :

@MetaProperty(related = {“sess1_start”, “sess1_end”})
public Long getSess1Hours() {
try {
long diff = sess1_end.getTime() - sess1_start.getTime();
if(diff < 1) {
sess1_end.setTime(sess1_end.getTime() + TimeUnit.HOURS.toMillis(24));
diff = diff + TimeUnit.HOURS.toMillis(24);
}
long hours = TimeUnit.MILLISECONDS.toHours(diff);
if(diff - TimeUnit.HOURS.toMillis(hours) > 0) {
++hours;
}

return hours;
} catch (Exception ex) {
return 0L;
}
}

I have thought of using @JmixProperty annotation but is there any better replacement for Cuba’s Attribute Annotations @MetaProperty in Jmix 2.x version ?

Hi @shoongcheng.choi
@JmixProperty is the correct replacement.
See how it is used with a method-based attribute here: Entities :: Jmix Documentation

1 Like

Hi @krivopustov ,
Thanks for the answer, I will check it out the link u sent to me.