How to implement a Spring Data repository for a @MappedSuperclass

It’s just a matter of annotating the abstract Repository as @NoRepositoryBean: @NoRepositoryBean public interface Dao<T extends BaseClass, E extends Serializable> extends CrudRepository<T, E> { Iterable<T> findByActive(Boolean active); } This way Spring relies on the underlying repository implementation to execute the findByActive method. Regarding to the annotation type restriction issue, it’s not possible to declare an … Read more

How can I create a generic array in Java?

I have to ask a question in return: is your GenSet “checked” or “unchecked”? What does that mean? Checked: strong typing. GenSet knows explicitly what type of objects it contains (i.e. its constructor was explicitly called with a Class<E> argument, and methods will throw an exception when they are passed arguments that are not of … Read more

Java 8 Generics: Reducing a Stream of Consumers to a single Consumer

You use a one-argument Stream.reduce(accumulator) version that has the following signature: Optional<T> reduce(BinaryOperator<T> accumulator); The BinaryOperator<T> accumulator can only accept elements of type T, but you have: <? extends Consumer<? super T>> I propose you to use a three-argument version of the Stream.reduce(…) method instead: <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator … Read more

Method in the type Map is not applicable

? extends Object You are using generic wildcard. You cannot perform add operation as class type is not determinate. You cannot add/put anything(except null). For more details on using wildcard you can refer oracle docs. Collection<?> c = new ArrayList<String>(); c.add(new Object()); // Compile time error Since we don’t know what the element type of … Read more

How to free a generic TList?

Executive summary MyList.Free is sufficient. Detailed answer The TList<T> generic container owns its contents. When you free the container, the contents are also disposed of. Now, if T is an unmanaged reference, either a pointer or a class, then the list owns the reference. It does not own that which the reference refers to. So … Read more

Java ternary operator influence on generics type inference

Compiles for me fine in java 8. Earlier versions of Java might need more help return retval == null ? Collections.<String>emptyList() : retval; should work. EDIT This is due to improvements in Java 8 type inference as explained here http://openjdk.java.net/jeps/101 And here’s a blog with the highlights: http://blog.jooq.org/2013/11/25/a-lesser-known-java-8-feature-generalized-target-type-inference/

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)