You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Robert Scala <rs...@buyersedgepurchasing.com> on 2019/02/06 21:05:30 UTC
@Converter(autoApply=true)
Hello,
I'm trying OpenJPA 3.0.0 so I can use the AttributeConverter annotation.
But I'm having problems. My converter is simple:
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter(autoApply = true)
public class StringInternConverter implements AttributeConverter<String,
String>
{
@Override
public String convertToDatabaseColumn(String attribute)
{
return attribute;
}
@Override
public String convertToEntityAttribute(String dbData)
{
return dbData != null ? dbData.intern(): null;
}
}
The problem is that I can't get JPA to see this converter. When I add
it to persistence.xml like this:
<!-- Converters -->
<class>com.be.db.jpa.StringInternConverter</class>
The enhancer complains that it StringInternConverter "does not have
persistence metadata".
Is there a trick to get this to work?
Thanks,
Rob
--
Rob Scala
Buyers Edge, Inc.
351 North Frontage Road, Suite A210
New London, CT 06320
Phone: (860) 865-2127
Re: @Converter(autoApply=true)
Posted by Robert Scala <rs...@buyersedgepurchasing.com>.
Thanks, Mark. I'll check it out when I get some time. Can you point me
to some documentation?
On 2/7/19 3:12 AM, Mark Struberg wrote:
> Hi Rob!
> Thanks for your example!
> I'll gonna check your sample and try to get it working.It's likely not working in 3.0.0 right now, but we try to fix it for 3.0.1.
> What you can do in the meantime is to use a ValueHandler instead.
> This is the OpenJPA specific version which predates the JPA @Converter logic.
> rsandtner/openjpa-converter
>
> |
> |
> |
> | | |
>
> |
>
> |
> |
> | |
> rsandtner/openjpa-converter
>
> Contribute to rsandtner/openjpa-converter development by creating an account on GitHub.
> |
>
> |
>
> |
>
>
>
>
> LieGrue,strub
>
> On Wednesday, 6 February 2019, 22:05:48 CET, Robert Scala <rs...@buyersedgepurchasing.com> wrote:
>
> Hello,
>
> I'm trying OpenJPA 3.0.0 so I can use the AttributeConverter annotation.
>
> But I'm having problems. My converter is simple:
>
> import javax.persistence.AttributeConverter;
> import javax.persistence.Converter;
>
> @Converter(autoApply = true)
> public class StringInternConverter implements AttributeConverter<String,
> String>
> {
> @Override
> public String convertToDatabaseColumn(String attribute)
> {
> return attribute;
> }
>
> @Override
> public String convertToEntityAttribute(String dbData)
> {
> return dbData != null ? dbData.intern(): null;
> }
> }
>
> The problem is that I can't get JPA to see this converter. When I add
> it to persistence.xml like this:
>
> <!-- Converters -->
> <class>com.be.db.jpa.StringInternConverter</class>
>
> The enhancer complains that it StringInternConverter "does not have
> persistence metadata".
>
> Is there a trick to get this to work?
>
> Thanks,
>
> Rob
>
>
--
Rob Scala
Buyers Edge, Inc.
351 North Frontage Road, Suite A210
New London, CT 06320
Phone: (860) 865-2127
Re: @Converter(autoApply=true)
Posted by Mark Struberg <st...@yahoo.de.INVALID>.
Hi Rob!
Thanks for your example!
I'll gonna check your sample and try to get it working.It's likely not working in 3.0.0 right now, but we try to fix it for 3.0.1.
What you can do in the meantime is to use a ValueHandler instead.
This is the OpenJPA specific version which predates the JPA @Converter logic.
rsandtner/openjpa-converter
|
|
|
| | |
|
|
|
| |
rsandtner/openjpa-converter
Contribute to rsandtner/openjpa-converter development by creating an account on GitHub.
|
|
|
LieGrue,strub
On Wednesday, 6 February 2019, 22:05:48 CET, Robert Scala <rs...@buyersedgepurchasing.com> wrote:
Hello,
I'm trying OpenJPA 3.0.0 so I can use the AttributeConverter annotation.
But I'm having problems. My converter is simple:
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter(autoApply = true)
public class StringInternConverter implements AttributeConverter<String,
String>
{
@Override
public String convertToDatabaseColumn(String attribute)
{
return attribute;
}
@Override
public String convertToEntityAttribute(String dbData)
{
return dbData != null ? dbData.intern(): null;
}
}
The problem is that I can't get JPA to see this converter. When I add
it to persistence.xml like this:
<!-- Converters -->
<class>com.be.db.jpa.StringInternConverter</class>
The enhancer complains that it StringInternConverter "does not have
persistence metadata".
Is there a trick to get this to work?
Thanks,
Rob
--
Rob Scala
Buyers Edge, Inc.
351 North Frontage Road, Suite A210
New London, CT 06320
Phone: (860) 865-2127