<commit_before>
package ${model.package};

import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import org.bridje.ioc.Ioc;
import org.bridje.ioc.Inject;
import org.bridje.ioc.thls.Thls;
import org.bridje.sql.*;
import org.bridje.orm.*;
import javax.annotation.Generated;

/**
 * This class represents the ${model.name} data model.
 * it must be use to read and write ${model.name} entities.
 * The full list of ${model.name} entities is the following.
 * <ul>
<#list model.entities as entity >
 * <li>${entity.name}<br></li>
</#list>
 * </ul>
 */
@Generated(value = "org.bridje.orm.srcgen.OrmSourceGenerator", date = "${.now?string("yyyy-MM-dd")}", comments = "Generated by Bridje ORM API")
public class ${model.name}Base
{
    public static final Schema SCHEMA;

    static final Set<Class<?>> ENTITIES;

    static final Map<Class<?>, EntityValueFinder> TO_KEYS;

    static final Map<Class<?>, EntityValueFinder> TO_ENTITIES;

    static {
        SCHEMA = SQL.buildSchema("${model.schema}")
                    <#list model.entities as entity>
                    .table(${entity.name}.TABLE)
                    </#list>
                    <#list model.entities as entity>
                    <#list entity.foreignKeys![] as key>
                    <#if !key.isWithItSelf>
                    .foreignKey(SQL.buildForeignKey(${entity.name}.TABLE, ${entity.name}.${key.column?upper_case})
                                    .references(${key.with.name}.TABLE)
                                    .strategy(ForeignKeyStrategy.${key.onUpdate}, ForeignKeyStrategy.${key.onDelete})
                                    .build())
                    </#if>
                    </#list>
                    </#list>
                    .build();

        ENTITIES = new HashSet<>();
        <#list model.entities as entity>
        ENTITIES.add(${entity.name}.class);
        </#list>

        TO_KEYS = new HashMap<>();
        <#list model.entities as entity>
        TO_KEYS.put(${entity.name}.class, (v) -> ((${entity.name})v).getId());
        </#list>

        TO_ENTITIES = new HashMap<>();
        <#list model.entities as entity>
        TO_ENTITIES.put(${entity.name}.class, (v) -> get().find${entity.name}(((${entity.key.type.javaType})v)));
        </#list>
        
    }

    public static ${model.name} get()
    {
        return Thls.get(ORMEnvironment.class).getModel(${model.name}.class);
    }

    @Inject
    protected EntityContext ctx;

    @Inject
    protected SQLEnvironment env;
<commit_msg>Adding generic methods in the orm model.<commit_after>
package ${model.package};

import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import org.bridje.ioc.Ioc;
import org.bridje.ioc.Inject;
import org.bridje.ioc.thls.Thls;
import org.bridje.sql.*;
import org.bridje.orm.*;
import javax.annotation.Generated;

/**
 * This class represents the ${model.name} data model.
 * it must be use to read and write ${model.name} entities.
 * The full list of ${model.name} entities is the following.
 * <ul>
<#list model.entities as entity >
 * <li>${entity.name}<br></li>
</#list>
 * </ul>
 */
@Generated(value = "org.bridje.orm.srcgen.OrmSourceGenerator", date = "${.now?string("yyyy-MM-dd")}", comments = "Generated by Bridje ORM API")
public class ${model.name}Base
{
    public static final Schema SCHEMA;

    static final Set<Class<?>> ENTITIES;

    static final Map<Class<?>, EntityValueFinder> TO_KEYS;

    static final Map<Class<?>, EntityValueFinder> TO_ENTITIES;

    static {
        SCHEMA = SQL.buildSchema("${model.schema}")
                    <#list model.entities as entity>
                    .table(${entity.name}.TABLE)
                    </#list>
                    <#list model.entities as entity>
                    <#list entity.foreignKeys![] as key>
                    <#if !key.isWithItSelf>
                    .foreignKey(SQL.buildForeignKey(${entity.name}.TABLE, ${entity.name}.${key.column?upper_case})
                                    .references(${key.with.name}.TABLE)
                                    .strategy(ForeignKeyStrategy.${key.onUpdate}, ForeignKeyStrategy.${key.onDelete})
                                    .build())
                    </#if>
                    </#list>
                    </#list>
                    .build();

        ENTITIES = new HashSet<>();
        <#list model.entities as entity>
        ENTITIES.add(${entity.name}.class);
        </#list>

        TO_KEYS = new HashMap<>();
        <#list model.entities as entity>
        TO_KEYS.put(${entity.name}.class, (v) -> ((${entity.name})v).get${entity.key.name?cap_first}());
        </#list>

        TO_ENTITIES = new HashMap<>();
        <#list model.entities as entity>
        TO_ENTITIES.put(${entity.name}.class, (v) -> get().find${entity.name}(((${entity.key.type.javaType})v)));
        </#list>
        
    }

    public static ${model.name} get()
    {
        return Thls.get(ORMEnvironment.class).getModel(${model.name}.class);
    }

    @Inject
    protected EntityContext ctx;

    @Inject
    protected SQLEnvironment env;

{'fraction_non_alphanumeric': 0.152433251278167, 'fraction_numerical': 0.0, 'mean_word_length': 2.1896135265700485, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4444499', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1601, 'n_words': 340}