title: Get string minimum from recursive hibernate query
body: <p>I have an entity that has a ManyToMany relationship with itself:</p>
  
  <pre><code>@Entity
  @Table(name = "asset")
  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
  public class Asset implements Serializable {
  
  private static final long serialVersionUID = 1L;
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;
  
  @Enumerated(EnumType.STRING)
  @Column(name = "provided_c")
  private EnumerationClass providedC; // A0, A1, A2, ...
  
  @ManyToMany
  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
  @JoinTable(name = "asset_dependencies",
      joinColumns = @JoinColumn(name = "assets_id",  `referencedColumnName = "id"),`
      inverseJoinColumns = @JoinColumn(name = "dependencies_id", referencedColumnName = "id"))
  private Set&lt;Asset&gt; dependencies = new HashSet&lt;&gt;();
  </code></pre>
  
  <p>When I call this query in my Spring Data repository I do get all Assets and the depending ones.</p>
  
  <pre><code>@Query(value = "select distinct asset from Asset supporting_asset left join fetch asset.dependencies")
  List&lt;Asset&gt; findAllWithEagerRelationships();
  </code></pre>
  
  <p>But I need to get another calculated field.
  All assets have a categorisation (providedC: A0 -A3). The calculated field would be the lowest category of all assets, this asset depends on.</p>
  
  <p>Is there a good way to achieve this? 
  Or what would be the right approach?</p>