Okay, I looked at the spec a bit closer and it looks like we need to allow
for floats as primary keys:

"The primary key (or field or property of a composite primary key) should be
one of the following types:
any Java primitive type; any primitive wrapper type; java.lang.String;
java.util.Date;
java.sql.Date. In general, however, approximate numeric types (e.g.,
floating point types) should
never be used in primary keys."

Although the spec clearly recommends against the use of floating points,
floats are a primitive type (or the Float wrapper) and need to be allowed.
With no special "AllowStupidApproximatePrimaryKeys" flag.  :-)

Am I trying to read too much into the spec or Dain's request?  This seems to
be something that we need to support.

Kevin

On 4/11/07, Kevin Sutter <[EMAIL PROTECTED]> wrote:

Dain,
When you mention the "CMP test suite" are you referring to the CTS TCK?
If so, how does "CMP" correspond to EJB's and their use of JPA (in the EJB3
sense)?  I understand your request.  I'm just trying to understand whether
this is a "requirement" or just a bad test case in the CTS TCK.  The JPA
spec is pretty clear that approximate types should never be used for primary
keys -- although I suppose you could read it that some providers could allow
this use.  It just wouldn't be portable.

Kevin

On 4/10/07, Dain Sundstrom <[EMAIL PROTECTED]> wrote:
>
> I know it is a really really really stupid idea to use an approximate
> type at a primary key, but there is a test in the CMP test suite that
> uses a float for a primary key.  When I deploy this bean, I get an
> exception like the following:
>
> Caused by: <0.9.7-incubating-SNAPSHOT fatal user error>
> org.apache.openjpa.persistence.ArgumentException: Type "class
> foo.FloatBeanEJB" declares field "cmpID" as a primary key, but keys
> of type "java.lang.Float" are not supported.
>      at org.apache.openjpa.meta.ClassMetaData.validateAppIdClass
> (ClassMetaData.java:1800)
>      at org.apache.openjpa.meta.ClassMetaData.validateIdentity
> (ClassMetaData.java:1779)
>      at org.apache.openjpa.meta.ClassMetaData.validateMeta
> (ClassMetaData.java:1696)
>      at org.apache.openjpa.meta.ClassMetaData.resolve
> (ClassMetaData.java:1569)
>      at org.apache.openjpa.meta.MetaDataRepository.processBuffer
> (MetaDataRepository.java:656)
>      at org.apache.openjpa.meta.MetaDataRepository.resolveMeta
> (MetaDataRepository.java:556)
>      at org.apache.openjpa.meta.MetaDataRepository.resolve
> (MetaDataRepository.java :481)
>      at org.apache.openjpa.meta.MetaDataRepository.getMetaData
> (MetaDataRepository.java:285)
>      at org.apache.openjpa.meta.MetaDataRepository.resolveMeta
> (MetaDataRepository.java:521)
>      at org.apache.openjpa.meta.MetaDataRepository.resolve
> (MetaDataRepository.java:481)
>      at org.apache.openjpa.meta.MetaDataRepository.getMetaData
> (MetaDataRepository.java:285)
>      at org.apache.openjpa.jdbc.meta.MappingRepository.getMapping
> (MappingRepository.java :276)
>      at org.apache.openjpa.jdbc.meta.MappingTool.getMapping
> (MappingTool.java:667)
>      at org.apache.openjpa.jdbc.meta.MappingTool.buildSchema
> (MappingTool.java:739)
>      at org.apache.openjpa.jdbc.meta.MappingTool.run (MappingTool.java:
> 637)
>      at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings
> (JDBCBrokerFactory.java:161)
>      at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl
> (JDBCBrokerFactory.java :127)
>      at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker
> (AbstractBrokerFactory.java:171)
>      at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker
> (DelegatingBrokerFactory.java:139)
>      at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityMana
> ger(EntityManagerFactoryImpl.java:187)
>      at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityMana
> ger(EntityManagerFactoryImpl.java :52)
>
> Is there any way I can turn off this warning?  Maybe we can add an
> "AllowStupidApproximatePrimaryKeys" flag.
>
> Please :)
>
> -dain
>


Reply via email to