Skip to content

Commit

Permalink
[hibernate#856] Support property JDBC_TIME_ZONE for time types
Browse files Browse the repository at this point in the history
We cannot apply a timezone to a time without a date,
this probably the best we can do without throwing
an exception.
  • Loading branch information
DavideD committed Jun 14, 2021
1 parent 5587b8a commit e0d10f5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ public void setTime(int parameterIndex, Time x) {
put( parameterIndex, x.toLocalTime() );
}

@Override
public void setTime(int parameterIndex, Time x, Calendar cal) {
put( parameterIndex, x.toLocalTime() );
}

@Override
public void setTimestamp(int parameterIndex, Timestamp x) {
put( parameterIndex, x.toLocalDateTime() );
Expand Down Expand Up @@ -242,11 +247,6 @@ public void setDate(int parameterIndex, Date x, Calendar cal) {
put( parameterIndex, x.toLocalDate() );
}

@Override
public void setTime(int parameterIndex, Time x, Calendar cal) {
throw new UnsupportedOperationException();
}

@Override
public void setNull(int parameterIndex, int sqlType, String typeName) {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ public Time getTime(int columnIndex) {
return (wasNull=localTime==null) ? null : Time.valueOf(localTime);
}

@Override
public Time getTime(int columnIndex, Calendar cal) {
LocalTime localTime = row.getLocalTime(columnIndex);
return (wasNull=localTime==null) ? null : Time.valueOf(localTime);
}

@Override
public Timestamp getTimestamp(int columnIndex) {
LocalDateTime localDateTime = row.getLocalDateTime(columnIndex);
Expand Down Expand Up @@ -251,6 +257,12 @@ public Time getTime(String columnLabel) {
return (wasNull=localTime==null) ? null : Time.valueOf(localTime);
}

@Override
public Time getTime(String columnLabel, Calendar cal) {
LocalTime localTime = row.getLocalTime( columnLabel );
return ( wasNull = localTime == null ) ? null : Time.valueOf( localTime );
}

@Override
public Timestamp getTimestamp(String columnLabel) {
Object rawValue = row.getValue(columnLabel);
Expand Down Expand Up @@ -711,16 +723,6 @@ public Date getDate(String columnLabel, Calendar cal) {
throw new UnsupportedOperationException();
}

@Override
public Time getTime(int columnIndex, Calendar cal) {
throw new UnsupportedOperationException();
}

@Override
public Time getTime(String columnLabel, Calendar cal) {
throw new UnsupportedOperationException();
}

@Override
public Timestamp getTimestamp(int columnIndex, Calendar cal) {
throw new UnsupportedOperationException();
Expand Down

0 comments on commit e0d10f5

Please sign in to comment.