<commit_before>package ar.com.bamboo.security

import ar.com.bamboo.commonsEntity.Person
import ar.com.bamboo.framework.domains.BaseEntity

class User extends BaseEntity{

    transient springSecurityService
    transient passwordNoEncoding

    String username
    String password
    boolean accountExpired
    boolean accountLocked
    boolean passwordExpired
    boolean acceptedTermCondition
    boolean accountVerified
    Date termConditionDateAccept
    Date dateAccountVerified
    Person person

    static transients = ['springSecurityService']

    static constraints = {
        username blank: false, unique: true, email: true
        password blank: false
        termConditionDateAccept nullable: true
        dateAccountVerified nullable: true
    }

    static mapping = {
        password column: '`password`'
        person fetch: 'join', cache: true
        cache usage: 'nonstrict-read-write'
    }

    Set<Role> getAuthorities() {
        UserRole.findAllByUser(this).collect { it.role }
    }

    @Override
    protected void executeMoreBeforeInsert() {
        encodePassword()
        acceptedTermCondition = false
        accountVerified = false
    }

    def beforeUpdate() {
        if (isDirty('password')) {
            encodePassword()
        }<commit_msg>vuelvo atrás el fetch: join de user con person porque trae problemas con la second caché<commit_after>package ar.com.bamboo.security

import ar.com.bamboo.commonsEntity.Person
import ar.com.bamboo.framework.domains.BaseEntity

class User extends BaseEntity{

    transient springSecurityService
    transient passwordNoEncoding

    String username
    String password
    boolean accountExpired
    boolean accountLocked
    boolean passwordExpired
    boolean acceptedTermCondition
    boolean accountVerified
    Date termConditionDateAccept
    Date dateAccountVerified
    Person person

    static transients = ['springSecurityService']

    static constraints = {
        username blank: false, unique: true, email: true
        password blank: false
        termConditionDateAccept nullable: true
        dateAccountVerified nullable: true
    }

    static mapping = {
        password column: '`password`'
        person lazy: false, cache: true
        cache usage: 'nonstrict-read-write'
    }

    Set<Role> getAuthorities() {
        UserRole.findAllByUser(this).collect { it.role }
    }

    @Override
    protected void executeMoreBeforeInsert() {
        encodePassword()
        acceptedTermCondition = false
        accountVerified = false
    }

    def beforeUpdate() {
        if (isDirty('password')) {
            encodePassword()
        }
{'fraction_non_alphanumeric': 0.0636055701919458, 'fraction_numerical': 0.0, 'mean_word_length': 2.841040462427746, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2136544', 'n_tokens_mistral': 687, 'n_tokens_neox': 666, 'n_words': 187}