blob: 25b14a05935a585615087648ad99a81dbeda1215 [file] [log] [blame]
/*
* Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016 IBM Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// 12/05/2016-2.6 Jody Grassel
// - 443546: Converter autoApply does not work for primitive types
package org.eclipse.persistence.jpa.converter.converters;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter(autoApply=true)
public class BooleanToStringAutoApplyConverter implements AttributeConverter<Boolean, String> {
public static boolean convertToDatabaseTriggered = false;
public static boolean convertToEntityTriggered = false;
public static Boolean ctdcVal = null;
public static String cteaVal = null;
public static void reset() {
convertToDatabaseTriggered = false;
convertToEntityTriggered = false;
ctdcVal = null;
cteaVal = null;
}
@Override
public String convertToDatabaseColumn(Boolean attribute) {
convertToDatabaseTriggered = true;
ctdcVal = attribute;
return Boolean.toString(attribute);
}
@Override
public Boolean convertToEntityAttribute(String dbData) {
convertToEntityTriggered = true;
cteaVal = dbData;
return Boolean.valueOf(dbData);
}
}