My question is a quite simple mapping question. I have an oracle database and i'm using toplink as jpa implementation. I want to persist a pojo that contains a boolean. In fact the toplink dialect will create NUMBER column with two possible values 1 or 0. But is there a standard way to force a different representation like the @Temporal(TemporalType.DATE) or the @Enumerated(EnumType.STRING).
Thanks in advance
Edvins Reisons
Ranch Hand
Joined: Dec 11, 2006
Posts: 364
posted
0
The boolean type, like the other Java primitive types, is mapped with the optional @Basic annotation. [ May 11, 2007: Message edited by: Edvins Reisons ]
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
Hello that's not exactly what i try to ask: Imagine you have an existing database where a column of a table represent a Boolean value with Varchar2(1). Which can be 'Y' or 'N'.
Is there a simple way to create an jpa mapping that will map this column to a boolean? Thanks in advance
Edvins Reisons
Ranch Hand
Joined: Dec 11, 2006
Posts: 364
posted
0
My understanding is that this customization can be done at the persistence provider level (I've seen similar customization options in Hibernate), rather than in JPA.
Oliver Kamps
Greenhorn
Joined: May 15, 2007
Posts: 18
posted
0
Hi,
the JPA specification itself does not specify how a boolean field is mapped to / represented in the database. You will have to look at your JPA implementation's documentation for vendor-specific extensions.
Having had the, err, opportunity to use TopLink (pre-JPA) in a previous life, I'd be surprised if TopLink didn't allow you to customize the mapping.
I don't know TopLink, but in Kodo JDO, it could be done either by defining fixed values in the vendor mapping support files (both for booleans and for enumerations) OR if you preferred, you could define a custom mapping class and bind it to the field.
One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"