Unverified Commit 4e4e14e0 authored by zhaojun's avatar zhaojun Committed by GitHub
Browse files

Merge pull request #123 from cherrylzhao/dev

make type of primary key generic.
parents c97edce7 dd75fead
Loading
Loading
Loading
Loading
+25 −3
Original line number Diff line number Diff line
@@ -19,17 +19,39 @@ package org.apache.shardingsphere.example.common.repository;

import java.util.List;

public interface CommonRepository<T> {
public interface CommonRepository<T, P> {
    
    /**
     * Create table if not exist.
     */
    void createTableIfNotExists();
    
    /**
     * Drop table.
     */
    void dropTable();
    
    /**
     * Truncate table.
     */
    void truncateTable();
    
    Long insert(T entity);
    /**
     * insert one entity.
     * @param entity entity
     * @return primary key
     */
    P insert(T entity);
    
    void delete(Long id);
    /**
     * Do delete.
     * @param key key
     */
    void delete(P key);
    
    /**
     * select all.
     * @return list of entity
     */
    List<T> selectAll();
}
+1 −1
Original line number Diff line number Diff line
@@ -19,5 +19,5 @@ package org.apache.shardingsphere.example.common.repository;

import org.apache.shardingsphere.example.common.entity.OrderItem;

public interface OrderItemRepository extends CommonRepository<OrderItem> {
public interface OrderItemRepository extends CommonRepository<OrderItem, Long> {
}
+1 −1
Original line number Diff line number Diff line
@@ -19,5 +19,5 @@ package org.apache.shardingsphere.example.common.repository;

import org.apache.shardingsphere.example.common.entity.Order;

public interface OrderRepository extends CommonRepository<Order> {
public interface OrderRepository extends CommonRepository<Order, Long> {
}
+1 −1
Original line number Diff line number Diff line
@@ -19,5 +19,5 @@ package org.apache.shardingsphere.example.common.repository;

import org.apache.shardingsphere.example.common.entity.User;

public interface UserRepository extends CommonRepository<User> {
public interface UserRepository extends CommonRepository<User, Long> {
}