Project

General

Profile

« Previous | Next » 

Revision 15f01b88

Added by Andreas Müller almost 4 years ago

fix #9081 fix handling of empty Partial during save and in Person.get/setLifespan

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/hibernate/PartialUserType.java
49 49
			throws HibernateException, SQLException {
50 50
		String partial = (String)StandardBasicTypes.STRING.nullSafeGet(rs, names, session, owner);
51 51
		Partial result = new Partial();
52
		if (partial == null) {
52
		if (partial == null || "00000000".equals(partial) || "0000000000000".equals(partial)) {
53 53
			return null;
54 54
		}else if (partial.length() != 8 &&  partial.length() != 13){
55 55
		    throw new HibernateException("Format for Partial not supported. Length mus be 8 or 13: " + partial);
......
79 79
        if (minute != null){
80 80
            result = result.with(DateTimeFieldType.minuteOfHour(), minute);
81 81
        }
82
		return result;
82
        return isEmptyOrNull(result)? null:result;
83 83
	}
84 84

  
85
	@Override
85
    private boolean isEmptyOrNull(Partial partial) {
86
        return partial == null ? true : partial.getValues().length == 0;
87
    }
88

  
89
    @Override
86 90
	public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index,
87 91
			SessionImplementor session) throws HibernateException, SQLException {
88
		if (value == null){
92
		if (isEmptyOrNull((Partial)value)){
89 93
			StandardBasicTypes.STRING.nullSafeSet(preparedStatement, null, index, session);
90 94
		}else {
91 95
			Partial p = ((Partial) value);

Also available in: Unified diff