All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.yadaframework.persistence.YadaMoneyConverter Maven / Gradle / Ivy

There is a newer version: 0.7.7.R4
Show newest version
package net.yadaframework.persistence;

import jakarta.persistence.AttributeConverter;

/**
 * JPA converter between Object representation "YadaMoney" and DB column "Long"
 *
 */
public class YadaMoneyConverter implements AttributeConverter {

	@Override
	public Long convertToDatabaseColumn(YadaMoney attribute) {
		if (attribute==null) {
			return 0l;
		}
		return attribute.getInternalValue();
	}

	@Override
	public YadaMoney convertToEntityAttribute(Long dbData) {
		if (dbData==null) {
			dbData = 0l;
		}
		YadaMoney result = YadaMoney.fromDatabaseColumn(dbData);
		return result;
	}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy