Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hibernate update #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion onebusaway-gtfs-hibernate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.1.GA</version>
<version>5.1.0.Final</version>
</dependency>

<!-- Test Scope -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.text.ParseException;

import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.usertype.UserType;
import org.onebusaway.gtfs.model.calendar.ServiceDate;

Expand Down Expand Up @@ -64,34 +65,34 @@ public Object deepCopy(Object value) throws HibernateException {
return new ServiceDate((ServiceDate) value);
}

@Override
public Object nullSafeGet(ResultSet rs, String[] names, Object owner)
throws HibernateException, SQLException {

String value = rs.getString(names[0]);

if (rs.wasNull())
return null;

try {
return ServiceDate.parseString(value);
} catch (ParseException ex) {
throw new SQLException("error parsing service date value: " + value, ex);
}
}

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index)
throws HibernateException, SQLException {

if (value == null) {
st.setNull(index, SQL_TYPES[0]);
} else {
ServiceDate serviceDate = (ServiceDate) value;
st.setString(index, serviceDate.getAsString());
}
}

@Override
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
throws HibernateException, SQLException {

String value = rs.getString(names[0]);

if (rs.wasNull())
return null;

try {
return ServiceDate.parseString(value);
} catch (ParseException ex) {
throw new SQLException("error parsing service date value: " + value, ex);
}
}
@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
throws HibernateException, SQLException {

if (value == null) {
st.setNull(index, SQL_TYPES[0]);
} else {
ServiceDate serviceDate = (ServiceDate) value;
st.setString(index, serviceDate.getAsString());
}
}
@Override
public Object assemble(Serializable cached, Object owner)
throws HibernateException {
Expand All @@ -110,4 +111,5 @@ public Object replace(Object original, Object target, Object owner)
return null;
return deepCopy(original);
}

}