-
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.
Add insert object and insert jsonb classes
- Loading branch information
Pablo Collins
committed
May 18, 2020
1 parent
7a66580
commit f089bff
Showing
3 changed files
with
35 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package gumdrop.sql; | ||
|
||
import java.util.function.Function; | ||
|
||
public class InsertJsonbColumn<T> extends InsertObjectColumn<T> { | ||
|
||
public InsertJsonbColumn(String name, Function<T, Object> getter) { | ||
super(name, getter); | ||
} | ||
|
||
@Override | ||
public void appendBind(StringBuilder bind) { | ||
bind.append("to_jsonb(?::jsonb)"); | ||
} | ||
|
||
} |
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,18 @@ | ||
package gumdrop.sql; | ||
|
||
import java.sql.PreparedStatement; | ||
import java.sql.SQLException; | ||
import java.util.function.Function; | ||
|
||
public class InsertObjectColumn<T> extends InsertColumn<T, Object> { | ||
|
||
public InsertObjectColumn(String name, Function<T, Object> getter) { | ||
super(name, getter); | ||
} | ||
|
||
@Override | ||
public void set(PreparedStatement ps, int idx, Object o) throws SQLException { | ||
ps.setObject(idx, o); | ||
} | ||
|
||
} |
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