<commit_before>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(entity.jpa.qualified_name) %>;

<%= description_javadoc_for(entity, "") %>@javax.annotation.Generated( "Domgen" )
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
@java.lang.SuppressWarnings( { "UnusedDeclaration", "JavaDoc" } )
<%
   jpa_queries = entity.queries.select {|q| !q.jpa.native? }
   if !jpa_queries.empty? %>@javax.persistence.NamedQueries( value = {
<%= jpa_queries.collect do |q|
  "  @javax.persistence.NamedQuery( name = #{entity.jpa.name}.#{Domgen::Naming.uppercase_constantize(q.name)}, query = \"#{q.jpa.query_string.gsub('"',"\\\"")}\", hints = {#{q.jpa.actual_hints.collect{|k,v| "@javax.persistence.QueryHint(name = \"#{k}\", value = \"#{v}\")"}.join(", ")}} )"
  end.join(",\n") %>
} )<% end %>
<%
   native_queries = entity.queries.select {|q| q.jpa.native? }
   if !native_queries.empty? %>@javax.persistence.NamedNativeQueries( value = {
<%= native_queries.collect { |q|
  result = ''
  result = ", resultClass = #{entity.jpa.name}.class" if q.jpa.native? && :select == q.query_type && q.result_entity?
  "  @javax.persistence.NamedNativeQuery( name = #{entity.jpa.name}.#{Domgen::Naming.uppercase_constantize(q.name)}, query = \"#{q.jpa.query_string.gsub('"',"\\\"")}\"#{result}, hints = {#{q.jpa.actual_hints.collect{|k,v| "@javax.persistence.QueryHint(name = \"#{k}\", value = \"#{v}\")"}.join(", ")}} )"
  }.join(",\n")
        %>
} )<% end -%>
@javax.persistence.Access( javax.persistence.AccessType.FIELD )
@javax.persistence.Entity( name = "<%= entity.jpa.jpql_name %>" )
<% if entity.extends.nil? -%>
<% if entity.direct_subtypes.size != 0 -%>
@javax.persistence.Inheritance( strategy = javax.persistence.InheritanceType.SINGLE_TABLE )
@javax.persistence.DiscriminatorColumn( name = "_type_", discriminatorType = javax.persistence.DiscriminatorType.STRING )
<% end -%>
@javax.persistence.Table( name = "<%= entity.jpa.table_name %>",
                          schema = "<%= entity.data_module.sql.schema %>",
                          uniqueConstraints = {<%=
  entity.attributes.select{|a|a.unique?}.collect{|a|
  "@javax.persistence.UniqueConstraint( columnNames = {\"#{a.sql.column_name}\"})"
  }.join(",\n                          ")
%>},
                          indexes = {<%= entity.sql.indexes.collect{|index|
        "@javax.persistence.Index(name =\"#{index.index_name}\", columnList = \"#{index.attribute_names.collect{|a| "#{entity.attribute_by_name(a).sql.column_name} ASC"}.join(", ")}\", unique = #{index.unique?} /* cluster = #{index.cluster?}, gist = #{index.gist?}, filter = \"#{index.filter}\", includeColumnList = \"#{index.include_attribute_names.collect{|a| "#{entity.attribute_by_name(a).sql.column_name} ASC"}.join(", ")}\",  */)"
        }.join(",\n                   ")
%>})
<% else -%>
@javax.persistence.DiscriminatorValue( value = "<%= entity.sql.discriminator %>" )
<% end -%>
<% if entity.read_only? && entity.data_module.repository.jpa.provider == :eclipselink %>
@org.eclipse.persistence.annotations.ReadOnly
<% end -%>
<% if entity.jpa.entity_listeners.size > 0 %>
@javax.persistence.EntityListeners( { <%= entity.jpa.entity_listeners.collect{|l| "#{l}.class"}.join(", ") %> } )
<% end -%>
@javax.persistence.Cacheable( <%= entity.jpa.cacheable? ? "true" : "false" %> )
<% if entity.data_module.repository.ee.version != '6' %>@javax.enterprise.inject.Vetoed
<% end -%>
<% entity.xor_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end -%>
<% entity.codependent_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end -%>
<% entity.dependency_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end -%>
<% entity.incompatible_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end -%>
<% entity.relationship_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end -%>
<% entity.cycle_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end %>
public <%= entity.abstract? ? "abstract " : "" %>class <%= entity.jpa.name %>
<%= entity.extends ?
  "    extends #{entity.data_module.entity_by_name(entity.extends).jpa.qualified_name}\n" :
  "    implements java.io.Serializable" %>
{
<% entity.declared_attributes.select { |a| !a.abstract? && a.jpa? && a.jpa.persistent? && a.text? && a.has_non_max_length? }.each do |attribute| %>
  public static final int <%= Domgen::Naming.uppercase_constantize(attribute.name) -%>_MAX_SIZE = <%= attribute.length -%>;
<% end %>
  private static final long serialVersionUID = 1;

<% if !entity.extends %>
  @javax.persistence.Transient
  private boolean _loaded;
  @javax.persistence.Transient
  private boolean _removed;
<% end %>
<% entity.queries.each do |query| %><%= description_javadoc_for(query) %>  public static final String <%= Domgen::Naming.uppercase_constantize(query.name) %> = "<%= query.qualified_name %>";
<%
  end
   entity.declared_attributes.select { |a| !a.abstract? && a.jpa? && a.jpa.persistent? }.each do |attribute| %>
<%= j_jpa_field_attributes(attribute) -%>  private <%= attribute.jpa.java_type %> <%= attribute.jpa.field_name %>;
<% if !attribute.immutable? && entity.jpa.track_changes? -%>
  @javax.persistence.Transient
  private <%= attribute.jpa.java_type %> <%= attribute.jpa.field_name %>Original;
<% if attribute.jpa.fetch_type == :lazy -%>
  @javax.persistence.Transient
  private boolean <%= attribute.jpa.field_name %>Recorded;
<% end -%>
<% end -%>
<% end %>
<% entity.referencing_attributes.
  select { |attribute| !(attribute.abstract? || attribute.inherited?) && attribute.inverse.jpa? && attribute.inverse.jpa.traversable? }.
  each do |attribute| %><%= j_declared_relation(attribute) %>
<% end %>
<%= j_constructors(entity) %>
<%= j_declared_attribute_and_relation_accessors(entity) %>
<%= j_equals_method(entity) %>
<%= j_to_string_methods(entity) -%>

<% if !entity.extends -%>
  protected final boolean loaded()
  {
    return _loaded;
  }

  protected final boolean removed()
  {
    return _removed;
  }

  protected final void verifyNotRemoved()
  {
    if( removed() )
    {
      throw new IllegalStateException( "Attempting to manipulate entity that has been removed" );
    }
  }
<% end -%>

<% if entity.jpa.track_changes? -%>
  @javax.persistence.PostLoad
  protected void postLoad()
  {
<% if entity.extends -%>
    super.postLoad();
<% else -%>
    _loaded = true;
<% end -%>
<% entity.declared_attributes.select { |a| !a.immutable? && !a.abstract? && a.jpa? && a.jpa.persistent? && a.jpa.fetch_type == :eager }.each do |attribute| -%>
    <%= attribute.jpa.field_name %>Original = <%= attribute.jpa.field_name %>;
<% end -%>
  }

  public boolean unmodified()
  {
    return
      loaded() &&
<% if entity.extends -%>
      super.unmodified() &&
<% end -%>
<% entity.declared_attributes.select { |a| !a.immutable? && !a.abstract? && a.jpa? && a.jpa.persistent? && a.jpa.fetch_type == :eager }.each do |attribute| -%>
<% if attribute.nullable? -%>
      ((<%= attribute.jpa.field_name %>Original == null &&  <%= attribute.jpa.field_name %> == null) || (<%= attribute.jpa.field_name %>Original != null && <%= attribute.jpa.field_name %>Original.equals( <%= attribute.jpa.field_name %> ) ) ) &&
<% elsif attribute.text? || attribute.date? || attribute.datetime? || attribute.geometry? -%>
      <%= attribute.jpa.field_name %>Original.equals( <%= attribute.jpa.field_name %> ) &&
<% else -%>
      <%= attribute.jpa.field_name %>Original == <%= attribute.jpa.field_name %> &&
<% end -%>
<% end -%>
<% entity.declared_attributes.select { |a| !a.immutable? && !a.abstract? && a.jpa? && a.jpa.persistent? && a.jpa.fetch_type == :lazy }.each do |attribute| -%>
<% if attribute.nullable? -%>
      (!<%= attribute.jpa.field_name %>Recorded || ((<%= attribute.jpa.field_name %>Original == null &&  <%= attribute.jpa.field_name %> == null) || (<%= attribute.jpa.field_name %>Original != null && <%= attribute.jpa.field_name %>Original.equals( <%= attribute.jpa.field_name %> ) ) ) &&
<% elsif attribute.text? || attribute.date? || attribute.datetime? || attribute.geometry? -%>
      (!<%= attribute.jpa.field_name %>Recorded || <%= attribute.jpa.field_name %>Original.equals( <%= attribute.jpa.field_name %> ) ) &&
<% else -%><commit_msg>Add yet another missing )<commit_after>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(entity.jpa.qualified_name) %>;

<%= description_javadoc_for(entity, "") %>@javax.annotation.Generated( "Domgen" )
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
@java.lang.SuppressWarnings( { "UnusedDeclaration", "JavaDoc" } )
<%
   jpa_queries = entity.queries.select {|q| !q.jpa.native? }
   if !jpa_queries.empty? %>@javax.persistence.NamedQueries( value = {
<%= jpa_queries.collect do |q|
  "  @javax.persistence.NamedQuery( name = #{entity.jpa.name}.#{Domgen::Naming.uppercase_constantize(q.name)}, query = \"#{q.jpa.query_string.gsub('"',"\\\"")}\", hints = {#{q.jpa.actual_hints.collect{|k,v| "@javax.persistence.QueryHint(name = \"#{k}\", value = \"#{v}\")"}.join(", ")}} )"
  end.join(",\n") %>
} )<% end %>
<%
   native_queries = entity.queries.select {|q| q.jpa.native? }
   if !native_queries.empty? %>@javax.persistence.NamedNativeQueries( value = {
<%= native_queries.collect { |q|
  result = ''
  result = ", resultClass = #{entity.jpa.name}.class" if q.jpa.native? && :select == q.query_type && q.result_entity?
  "  @javax.persistence.NamedNativeQuery( name = #{entity.jpa.name}.#{Domgen::Naming.uppercase_constantize(q.name)}, query = \"#{q.jpa.query_string.gsub('"',"\\\"")}\"#{result}, hints = {#{q.jpa.actual_hints.collect{|k,v| "@javax.persistence.QueryHint(name = \"#{k}\", value = \"#{v}\")"}.join(", ")}} )"
  }.join(",\n")
        %>
} )<% end -%>
@javax.persistence.Access( javax.persistence.AccessType.FIELD )
@javax.persistence.Entity( name = "<%= entity.jpa.jpql_name %>" )
<% if entity.extends.nil? -%>
<% if entity.direct_subtypes.size != 0 -%>
@javax.persistence.Inheritance( strategy = javax.persistence.InheritanceType.SINGLE_TABLE )
@javax.persistence.DiscriminatorColumn( name = "_type_", discriminatorType = javax.persistence.DiscriminatorType.STRING )
<% end -%>
@javax.persistence.Table( name = "<%= entity.jpa.table_name %>",
                          schema = "<%= entity.data_module.sql.schema %>",
                          uniqueConstraints = {<%=
  entity.attributes.select{|a|a.unique?}.collect{|a|
  "@javax.persistence.UniqueConstraint( columnNames = {\"#{a.sql.column_name}\"})"
  }.join(",\n                          ")
%>},
                          indexes = {<%= entity.sql.indexes.collect{|index|
        "@javax.persistence.Index(name =\"#{index.index_name}\", columnList = \"#{index.attribute_names.collect{|a| "#{entity.attribute_by_name(a).sql.column_name} ASC"}.join(", ")}\", unique = #{index.unique?} /* cluster = #{index.cluster?}, gist = #{index.gist?}, filter = \"#{index.filter}\", includeColumnList = \"#{index.include_attribute_names.collect{|a| "#{entity.attribute_by_name(a).sql.column_name} ASC"}.join(", ")}\",  */)"
        }.join(",\n                   ")
%>})
<% else -%>
@javax.persistence.DiscriminatorValue( value = "<%= entity.sql.discriminator %>" )
<% end -%>
<% if entity.read_only? && entity.data_module.repository.jpa.provider == :eclipselink %>
@org.eclipse.persistence.annotations.ReadOnly
<% end -%>
<% if entity.jpa.entity_listeners.size > 0 %>
@javax.persistence.EntityListeners( { <%= entity.jpa.entity_listeners.collect{|l| "#{l}.class"}.join(", ") %> } )
<% end -%>
@javax.persistence.Cacheable( <%= entity.jpa.cacheable? ? "true" : "false" %> )
<% if entity.data_module.repository.ee.version != '6' %>@javax.enterprise.inject.Vetoed
<% end -%>
<% entity.xor_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end -%>
<% entity.codependent_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end -%>
<% entity.dependency_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end -%>
<% entity.incompatible_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end -%>
<% entity.relationship_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end -%>
<% entity.cycle_constraints.select {|c| jpa_validation_in_jpa?(c) }.each do |c| %>
@<%= entity.jpa.name %>.<%= validation_name(c.name) %><% end %>
public <%= entity.abstract? ? "abstract " : "" %>class <%= entity.jpa.name %>
<%= entity.extends ?
  "    extends #{entity.data_module.entity_by_name(entity.extends).jpa.qualified_name}\n" :
  "    implements java.io.Serializable" %>
{
<% entity.declared_attributes.select { |a| !a.abstract? && a.jpa? && a.jpa.persistent? && a.text? && a.has_non_max_length? }.each do |attribute| %>
  public static final int <%= Domgen::Naming.uppercase_constantize(attribute.name) -%>_MAX_SIZE = <%= attribute.length -%>;
<% end %>
  private static final long serialVersionUID = 1;

<% if !entity.extends %>
  @javax.persistence.Transient
  private boolean _loaded;
  @javax.persistence.Transient
  private boolean _removed;
<% end %>
<% entity.queries.each do |query| %><%= description_javadoc_for(query) %>  public static final String <%= Domgen::Naming.uppercase_constantize(query.name) %> = "<%= query.qualified_name %>";
<%
  end
   entity.declared_attributes.select { |a| !a.abstract? && a.jpa? && a.jpa.persistent? }.each do |attribute| %>
<%= j_jpa_field_attributes(attribute) -%>  private <%= attribute.jpa.java_type %> <%= attribute.jpa.field_name %>;
<% if !attribute.immutable? && entity.jpa.track_changes? -%>
  @javax.persistence.Transient
  private <%= attribute.jpa.java_type %> <%= attribute.jpa.field_name %>Original;
<% if attribute.jpa.fetch_type == :lazy -%>
  @javax.persistence.Transient
  private boolean <%= attribute.jpa.field_name %>Recorded;
<% end -%>
<% end -%>
<% end %>
<% entity.referencing_attributes.
  select { |attribute| !(attribute.abstract? || attribute.inherited?) && attribute.inverse.jpa? && attribute.inverse.jpa.traversable? }.
  each do |attribute| %><%= j_declared_relation(attribute) %>
<% end %>
<%= j_constructors(entity) %>
<%= j_declared_attribute_and_relation_accessors(entity) %>
<%= j_equals_method(entity) %>
<%= j_to_string_methods(entity) -%>

<% if !entity.extends -%>
  protected final boolean loaded()
  {
    return _loaded;
  }

  protected final boolean removed()
  {
    return _removed;
  }

  protected final void verifyNotRemoved()
  {
    if( removed() )
    {
      throw new IllegalStateException( "Attempting to manipulate entity that has been removed" );
    }
  }
<% end -%>

<% if entity.jpa.track_changes? -%>
  @javax.persistence.PostLoad
  protected void postLoad()
  {
<% if entity.extends -%>
    super.postLoad();
<% else -%>
    _loaded = true;
<% end -%>
<% entity.declared_attributes.select { |a| !a.immutable? && !a.abstract? && a.jpa? && a.jpa.persistent? && a.jpa.fetch_type == :eager }.each do |attribute| -%>
    <%= attribute.jpa.field_name %>Original = <%= attribute.jpa.field_name %>;
<% end -%>
  }

  public boolean unmodified()
  {
    return
      loaded() &&
<% if entity.extends -%>
      super.unmodified() &&
<% end -%>
<% entity.declared_attributes.select { |a| !a.immutable? && !a.abstract? && a.jpa? && a.jpa.persistent? && a.jpa.fetch_type == :eager }.each do |attribute| -%>
<% if attribute.nullable? -%>
      ((<%= attribute.jpa.field_name %>Original == null &&  <%= attribute.jpa.field_name %> == null) || (<%= attribute.jpa.field_name %>Original != null && <%= attribute.jpa.field_name %>Original.equals( <%= attribute.jpa.field_name %> ) ) ) &&
<% elsif attribute.text? || attribute.date? || attribute.datetime? || attribute.geometry? -%>
      <%= attribute.jpa.field_name %>Original.equals( <%= attribute.jpa.field_name %> ) &&
<% else -%>
      <%= attribute.jpa.field_name %>Original == <%= attribute.jpa.field_name %> &&
<% end -%>
<% end -%>
<% entity.declared_attributes.select { |a| !a.immutable? && !a.abstract? && a.jpa? && a.jpa.persistent? && a.jpa.fetch_type == :lazy }.each do |attribute| -%>
<% if attribute.nullable? -%>
      (!<%= attribute.jpa.field_name %>Recorded || ((<%= attribute.jpa.field_name %>Original == null &&  <%= attribute.jpa.field_name %> == null) || (<%= attribute.jpa.field_name %>Original != null && <%= attribute.jpa.field_name %>Original.equals( <%= attribute.jpa.field_name %> ) ) ) ) &&
<% elsif attribute.text? || attribute.date? || attribute.datetime? || attribute.geometry? -%>
      (!<%= attribute.jpa.field_name %>Recorded || <%= attribute.jpa.field_name %>Original.equals( <%= attribute.jpa.field_name %> ) ) &&
<% else -%>
{'fraction_non_alphanumeric': 0.2143517448578692, 'fraction_numerical': 0.0005777675063554426, 'mean_word_length': 4.299755052051439, 'pattern_counts': {'":': 0, '<': 249, '<?xml version=': 0, '>': 251, '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': '7576108', 'n_tokens_mistral': 6499, 'n_tokens_neox': 6210, 'n_words': 908}