<commit_before>/* DO NOT EDIT: File is autogenerated */
package <%= object_type.schema.java.package %>;

import javax.annotation.Generated;
import javax.persistence.*;
import javax.validation.constraints.*;

@SuppressWarnings( { "UnusedDeclaration" } )
<% if not object_type.queries.empty? %>@NamedQueries( value = {
<%= object_type.queries.collect { |q| "  @NamedQuery( name = \"#{q.fully_qualified_name}\", query = \"#{q.query_string}\" )" }.join(",\n") %>
} )<% end %>
@Generated( "Domgen" )
@Entity
@Table( name = "<%= object_type.sql.table_name %>",
        uniqueConstraints = {<%=
  object_type.attributes.select{|a|a.unique?}.collect{|a|
  "@UniqueConstraint( columnNames = {\"#{q(a.sql.column_name)}\"})"
  }.join(",\n        ")
%>})
public final class <%= object_type.java.classname %>
{
<% object_type.attributes.each do |a|
  if !a.persistent?
%>  @Transient
<%
  else
    if a.primary_key?
%>  @Id
<%    if a.sql.identity?
%>  @GeneratedValue( strategy = GenerationType.IDENTITY )
<%
      end
    end
    if a.reference?
%>  @ManyToOne
  @JoinColumn( name = "<%= q(a.sql.column_name) %>", nullable = <%= a.nullable? %>, updatable = <%= !a.immutable? %> )<%
    else
%>  @Column( name = "<%= q(a.sql.column_name) %>"<%= a.length.nil? ? '' :", length = #{a.length}"%>, nullable = <%= a.nullable? %>, updatable = <%= !a.immutable? %> )<%
    end
   end
%>
<% if !a.nullable? && !a.sql.identity? %>  @NotNull
<% end %><% if !a.length.nil? %>  @Size(max = <%= a.length %>)
<% end %>  private <%= a.java.java_type %> <%= a.java.field_name %>;

<% end
   object_type.referencing_attributes.each do |attribute|
     if attribute.inverse_relationship_type == :has_many
%>  @OneToMany
  private java.util.Set<<%= attribute.object_type.java.fully_qualified_name %>> <%= pluralize(attribute.inverse_relationship_name) %>;

<% elsif attribute.inverse_relationship_type == :has_one
%>  @OneToOne(optional = <%= !attribute.nullable? %>, mappedBy= "<%= attribute.java.field_name %>")
  private <%= attribute.object_type.java.fully_qualified_name %> <%= attribute.inverse_relationship_name %>;

<%
    end
  end
%>
<%= object_type.attributes.collect {|a| java_accessors(a.java.field_name,a.java.java_type) }.join("\n") %>
<%= object_type.referencing_attributes.collect do |a|
  if a.inverse_relationship_type == :has_many
    java_accessors(pluralize(a.inverse_relationship_name),"java.util.Set<#{a.object_type.java.fully_qualified_name}>")
   elsif a.inverse_relationship_type == :has_one
    java_accessors(a.inverse_relationship_name,a.object_type.java.fully_qualified_name)
   else
    ''
   end
end.join("\n")
%>
  @Override
  public boolean equals( final Object o )
  {
    if ( this == o )
    {
      return true;
    }
    else if ( o == null || getClass() != o.getClass() )
    {
      return false;
    }
    else
    {
      final <%= object_type.java.classname %> that = (<%= object_type.java.classname %>) o;
      return getID() != null && getID().equals( that.getID() );
    }
  }

  public String toDebugString()
  {
    return "<%= object_type.name %>[" +
<% object_type.java.debug_attributes.each do |a|
    attr = object_type.attribute_by_name(a)
%>           "<%= attr.name %> =" + <%= attr.name %> + 
<% end %>           "]";
  }

  @Override
  public String toString()
  {
<% if !object_type.java.label_attribute.nil?
%>    return String.valueOf( <%= object_type.attribute_by_name(object_type.java.label_attribute).java.field_name %> );<% 
else
%>    return toDebugString();<% end %>
  }
}<commit_msg>Add another helper toLabel method<commit_after>/* DO NOT EDIT: File is autogenerated */
package <%= object_type.schema.java.package %>;

import javax.annotation.Generated;
import javax.persistence.*;
import javax.validation.constraints.*;

@SuppressWarnings( { "UnusedDeclaration" } )
<% if not object_type.queries.empty? %>@NamedQueries( value = {
<%= object_type.queries.collect { |q| "  @NamedQuery( name = \"#{q.fully_qualified_name}\", query = \"#{q.query_string}\" )" }.join(",\n") %>
} )<% end %>
@Generated( "Domgen" )
@Entity
@Table( name = "<%= object_type.sql.table_name %>",
        uniqueConstraints = {<%=
  object_type.attributes.select{|a|a.unique?}.collect{|a|
  "@UniqueConstraint( columnNames = {\"#{q(a.sql.column_name)}\"})"
  }.join(",\n        ")
%>})
public final class <%= object_type.java.classname %>
{
<% object_type.attributes.each do |a|
  if !a.persistent?
%>  @Transient
<%
  else
    if a.primary_key?
%>  @Id
<%    if a.sql.identity?
%>  @GeneratedValue( strategy = GenerationType.IDENTITY )
<%
      end
    end
    if a.reference?
%>  @ManyToOne
  @JoinColumn( name = "<%= q(a.sql.column_name) %>", nullable = <%= a.nullable? %>, updatable = <%= !a.immutable? %> )<%
    else
%>  @Column( name = "<%= q(a.sql.column_name) %>"<%= a.length.nil? ? '' :", length = #{a.length}"%>, nullable = <%= a.nullable? %>, updatable = <%= !a.immutable? %> )<%
    end
   end
%>
<% if !a.nullable? && !a.sql.identity? %>  @NotNull
<% end %><% if !a.length.nil? %>  @Size(max = <%= a.length %>)
<% end %>  private <%= a.java.java_type %> <%= a.java.field_name %>;

<% end
   object_type.referencing_attributes.each do |attribute|
     if attribute.inverse_relationship_type == :has_many
%>  @OneToMany
  private java.util.Set<<%= attribute.object_type.java.fully_qualified_name %>> <%= pluralize(attribute.inverse_relationship_name) %>;

<% elsif attribute.inverse_relationship_type == :has_one
%>  @OneToOne(optional = <%= !attribute.nullable? %>, mappedBy= "<%= attribute.java.field_name %>")
  private <%= attribute.object_type.java.fully_qualified_name %> <%= attribute.inverse_relationship_name %>;

<%
    end
  end
%>
<%= object_type.attributes.collect {|a| java_accessors(a.java.field_name,a.java.java_type) }.join("\n") %>
<%= object_type.referencing_attributes.collect do |a|
  if a.inverse_relationship_type == :has_many
    java_accessors(pluralize(a.inverse_relationship_name),"java.util.Set<#{a.object_type.java.fully_qualified_name}>")
   elsif a.inverse_relationship_type == :has_one
    java_accessors(a.inverse_relationship_name,a.object_type.java.fully_qualified_name)
   else
    ''
   end
end.join("\n")
%>
  @Override
  public boolean equals( final Object o )
  {
    if ( this == o )
    {
      return true;
    }
    else if ( o == null || getClass() != o.getClass() )
    {
      return false;
    }
    else
    {
      final <%= object_type.java.classname %> that = (<%= object_type.java.classname %>) o;
      return getID() != null && getID().equals( that.getID() );
    }
  }

  public String toDebugString()
  {
    return "<%= object_type.name %>[" +
<% object_type.java.debug_attributes.each do |a|
    attr = object_type.attribute_by_name(a)
%>           "<%= attr.name %> =" + <%= attr.name %> + 
<% end %>           "]";
  }

  public String toLabel()
  {
<% if !object_type.java.label_attribute.nil?
%>    return String.valueOf( <%= object_type.attribute_by_name(object_type.java.label_attribute).java.field_name %> );<%
else
      pk = object_type.primary_key
%>    return "<%= object_type.name %>[<%= pk.name %> = " + <%= pk.name %> +"]";<% end %>
  }

  @Override
  public String toString()
  {
<% if !object_type.java.label_attribute.nil?
%>    return toLabel();<% 
else
%>    return toDebugString();<% end %>
  }
}
{'fraction_non_alphanumeric': 0.19213375359736878, 'fraction_numerical': 0.0, 'mean_word_length': 3.8139841688654355, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 0, '>': 111, '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': '777837', 'n_tokens_mistral': 2759, 'n_tokens_neox': 2555, 'n_words': 417}