-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
231 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
package net.wonsi.column.type; | ||
|
||
public class BooleanType implements ColumnType { | ||
import lombok.NonNull; | ||
import lombok.SneakyThrows; | ||
|
||
import java.sql.ResultSet; | ||
|
||
public class BooleanType implements ColumnType<Boolean> { | ||
|
||
@Override | ||
public String convertToString(int length) { | ||
return "boolean"; | ||
} | ||
|
||
@Override | ||
@SneakyThrows | ||
public Boolean get(@NonNull String name, @NonNull ResultSet resultSet) { | ||
return resultSet.getBoolean(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
package net.wonsi.column.type; | ||
|
||
public interface ColumnType { | ||
import lombok.NonNull; | ||
|
||
import java.sql.ResultSet; | ||
|
||
public interface ColumnType<T> { | ||
String convertToString(int length); | ||
T get(@NonNull String name, @NonNull ResultSet resultSet); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
package net.wonsi.column.type; | ||
|
||
public class DateType implements ColumnType { | ||
import lombok.NonNull; | ||
import lombok.SneakyThrows; | ||
|
||
import java.sql.Date; | ||
import java.sql.ResultSet; | ||
|
||
public class DateType implements ColumnType<Date> { | ||
|
||
@Override | ||
public String convertToString(int length) { | ||
return "date"; | ||
} | ||
|
||
@Override | ||
@SneakyThrows | ||
public Date get(@NonNull String name, @NonNull ResultSet resultSet) { | ||
return resultSet.getDate(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
package net.wonsi.column.type; | ||
|
||
public class DatetimeType implements ColumnType { | ||
import lombok.NonNull; | ||
import lombok.SneakyThrows; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.Timestamp; | ||
|
||
public class DatetimeType implements ColumnType<Timestamp> { | ||
|
||
@Override | ||
public String convertToString(int length) { | ||
return "datetime"; | ||
} | ||
|
||
@Override | ||
@SneakyThrows | ||
public Timestamp get(@NonNull String name, @NonNull ResultSet resultSet) { | ||
return resultSet.getTimestamp(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
package net.wonsi.column.type; | ||
|
||
public class FloatType implements ColumnType { | ||
import lombok.NonNull; | ||
import lombok.SneakyThrows; | ||
|
||
import java.sql.ResultSet; | ||
|
||
public class FloatType implements ColumnType<Float> { | ||
|
||
@Override | ||
public String convertToString(int length) { | ||
return "float"; | ||
} | ||
|
||
@Override | ||
@SneakyThrows | ||
public Float get(@NonNull String name, @NonNull ResultSet resultSet) { | ||
return resultSet.getFloat(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
package net.wonsi.column.type; | ||
|
||
public class JsonType implements ColumnType { | ||
import lombok.NonNull; | ||
import lombok.SneakyThrows; | ||
|
||
import java.sql.ResultSet; | ||
|
||
public class JsonType implements ColumnType<String> { | ||
|
||
@Override | ||
public String convertToString(int length) { | ||
return "json"; | ||
} | ||
|
||
@Override | ||
@SneakyThrows | ||
public String get(@NonNull String name, @NonNull ResultSet resultSet) { | ||
return resultSet.getString(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
package net.wonsi.column.type; | ||
|
||
import java.util.Map; | ||
|
||
public class VarcharType implements ColumnType { | ||
import lombok.NonNull; | ||
import lombok.SneakyThrows; | ||
|
||
import java.sql.ResultSet; | ||
|
||
public class VarcharType implements ColumnType<String> { | ||
|
||
@Override | ||
public String convertToString(int length) { | ||
return "varchar(" + length + ')'; | ||
} | ||
|
||
@Override | ||
@SneakyThrows | ||
public String get(@NonNull String name, @NonNull ResultSet resultSet) { | ||
return resultSet.getString(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.wonsi.test; | ||
|
||
import lombok.SneakyThrows; | ||
import lombok.val; | ||
import net.wonsi.WonsiFactory; | ||
import net.wonsi.api.Wonsi; | ||
import net.wonsi.api.table.WonsiTable; | ||
import net.wonsi.test.model.Car; | ||
import net.wonsi.test.model.User; | ||
import net.wonsi.test.mysql.MySqlUtil; | ||
import net.wonsi.test.repo.UserRepo; | ||
|
||
public class TemplateRepoBootstrap { | ||
|
||
@SneakyThrows | ||
public static void main(String[] args) { | ||
Wonsi wonsi = WonsiFactory.createInstance(MySqlUtil.create()); | ||
WonsiTable<Car> table = wonsi.getTable(Car.class); | ||
|
||
val repository = table.createRepository(long.class); | ||
|
||
// repository.save(new Car(1, "BMW", "x3")); | ||
// repository.save(new Car(2, "BMW", "x5")); | ||
// repository.save(new Car(3, "BMW", "x7")); | ||
// repository.save(new Car(6, "BMW", "cla")); | ||
// | ||
// repository.save(new Car(9, "Porche", "911")); | ||
// repository.save(new Car(11, "Mersedes-Benz", "GLA")); | ||
|
||
System.out.println("[Test-Select] Model from row where id = 2: " + repository.findByIdentifier(2L).get().getModel()); | ||
|
||
System.out.println("[Find-All-Test] Items:"); | ||
for (val car: repository.findAll()) | ||
System.out.println(String.format(" #%s %s %s", car.getId(), car.getConcern(), car.getModel())); | ||
|
||
System.out.println("[Delete-Test] Trying to delete item with id=6"); | ||
repository.deleteByIdentifier(6L); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.