Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In Java, every generic type must be specified. You can go without specifying any type, but you can't go without specifying just one. </p> <p>Also, <strong>every</strong> generic type must be specified in the declaration. If you want to have <code>class GenericDAO&lt;T extends Identifable&lt;U&gt;&gt;</code>, you must add the generic type declaration for <code>U</code> to your class declaration like this (since <code>U</code> is actually a generic type here): </p> <pre><code>public abstract class GenericDAO&lt;T extends Identifable&lt;U&gt;, U&gt; </code></pre> <p>The following is partially off-topic, but you might find it useful.</p> <p>I've noticed that in your definition of <code>GenericDAO</code> two generic types are not tied to each other. This might not be what you want.</p> <p>What you have here is a particular case in which the two generics are matching (the <code>Long</code> type in the <code>Cat</code> and <code>CatDAO</code> definitions). Consider having these declarations:</p> <pre><code>public class Dog implements Identifable&lt;Long&gt; public class DogDAO extends GenericDao&lt;Dog, String&gt; </code></pre> <p>This would force you to write the <code>getById</code> method in <code>DogDAO</code> method:</p> <pre><code>Dog getById(String id); </code></pre> <p>Your <code>getId</code> method in the <code>Dog</code> returns a <code>Long</code> so your <code>getById</code> method int <code>DogDAO</code> would have to compare <code>String</code>s to <code>Long</code>s. This is valid thing to do, but it's a bit counter-intuitive. Having a <code>getById</code> method for <code>DogDAO</code> that takes a <code>Long</code> parameter makes more sense, since the <code>Dog</code>s IDs are actually <code>Long</code>s.</p> <p>If you want to tie the two types together, you can define the <code>GenericDAO</code> class as:</p> <pre><code>public abstract class GenericDAO&lt;T extends Identifable&lt;S&gt;, S&gt; </code></pre> <p>You still have to specify the second parameter, but at least the compiler can help you make sure that the types are matching.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload