/*
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.ts.tests.jpa.core.annotations.convert;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

@Converter(autoApply = true)
public class IntegerConverter implements AttributeConverter<Integer, Integer> {

    public Integer convertToDatabaseColumn(Integer attribute) {
        System.out.println("*** Entering IntegerConverter:convertToDatabaseColumn["+attribute+"] ***");
        Integer i =attribute;
        if (attribute >= 1000){
            i = attribute+100;
        }
        System.out.println("*** leaving IntegerConverter:convertToDatabaseColumn["+i+"] ***");

        return i;
    }

    public Integer convertToEntityAttribute(Integer dbData) {
        System.out.println("*** Entering IntegerConverter:convertToEntityAttribute["+dbData+"] ***");
        Integer i = dbData;
        if (dbData >= 1000){
            i = dbData+10;
        }
        System.out.println("*** Leaving IntegerConverter:convertToEntityAttribute["+i+"] ***");
        return i;

    }

}

