Hi, we are getting closer!

We added a strategy the uuid field

@Persistent
@Strategy("com.datastax.hectorjpa.strategy.NoOpHandler")
private UUID id;

So now it successfully enhances the class which now looks like this

@javax.persistence.metamodel.StaticMetamodel
(value=com.spidertracks.aviator.model.user.Phone.class)
@javax.annotation.Generated
(value="org.apache.openjpa.persistence.meta.AnnotationProcessor6",date="Wed
Jul 13 13:00:16 NZST 2011")
public class Phone_ {
    public static volatile SingularAttribute<Phone,String> countryIdd;
    public static volatile SingularAttribute<Phone,UUID> id;
    public static volatile SingularAttribute<Phone,String> iddCountryCode;
    public static volatile SingularAttribute<Phone,String> number;
    public static volatile SingularAttribute<Phone,PhoneType> type;
}

But when we go to load something it gets the list of fields, which includes
the id field, but this field is then stripped out when he meta data is
resolved.
This happens on line 164 of the ClassMetaData class in the resolveMeta
method and I get the following warning.

2011-07-13 03:16:23,295Z  WARN [main]  Field "
com.spidertracks.aviator.model.user.Phone.id" is not a type that is
persistent by default.  If you want this field to be persistent, you have to
explicitly set it to persistent in your metadata.

Thanks

On Wed, Jul 13, 2011 at 9:25 AM, Rick Curtis <curti...@gmail.com> wrote:

> Todd -
>
> I'm stretching a bit here as I've never actually experimented with this
> code.... but I'd start out by looking at
> org.apache.openjpa.persistence.jdbc.annotations.NonstandardMappingEntity
> and
>
> org.apache.openjpa.persistence.jdbc.annotations.TestNonstandardMappingAnnotations.
>
> It appears that you could add a @Strategy annotation to your UUID field and
> point it at your handler. That *should* auto-magically wire up the proper
> calls to you handler. If/when you get that working, it looks like you
> should
> be able to add this strategy(UUID->customer handler) to the mapping
> defaults.
>
> On Tue, Jul 12, 2011 at 3:58 PM, Todd Nine <t...@spidertracks.com> wrote:
>
> > Hey Rick,
> >  Adding the handler makes the field appear in the field list for my
> > plugin.  However my plugin currently doesn't support value handlers.  I
> > need to add this functionality, what is the best class to use as an
> > example for reading this meta data and invoking it at runtime?
> >
> > Thanks,
> > Todd
> >
> > On Tue, 2011-07-12 at 11:18 -0500, Rick Curtis wrote:
> >
> > > Todd -
> > >
> > > I don't think the problem is that the enhancer skips the field, its the
> > fact
> > > that we don't know how the map the UUID field. You might be able to
> write
> > a
> > > customer value handler [1] ? Take a look at that and see if it would
> work
> > > for you.
> > >
> > > Let me know how it goes.
> > >
> > > [1]
> > >
> >
> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_mapping_custom_vhandler
> > >
> > > On Sun, Jul 10, 2011 at 3:12 PM, Todd Nine <t...@spidertracks.com>
> > wrote:
> > >
> > > > Hey guys,
> > > >  I'm also involved in this project, I'm the developer for this
> plugin.
> > > >
> > > > https://github.com/riptano/hector-jpa/
> > > >
> > > > The UUID class is used extensively by quite a few Cassandra
> developers.
> > > > We've successfully used it as an identity, and my plug in recognizes
> > the
> > > > data type and can correctly serialize it.  However, when not used in
> > > > either a composite identity or an identity, it appears that Open JPA
> > > > does not correctly interpret the type and create an instance of a
> > > > persistent UUID in the list of fields for the entity.
> > > >
> > > > Here is  the UUID class we're using.
> > > >
> > > > http://johannburkard.de/software/uuid/
> > > >
> > > > I definitely want to provide native support for this value in my
> plugin
> > > > over string converter serialization.  How can I get the open JPA
> > > > enhancer to add it as a persistent field to the Entity during
> > > > enhancement?  I'll need to document this for my plugin, any help
> would
> > > > be greatly appreciated.
> > > >
> > > > Todd
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Fri, 2011-07-08 at 09:08 -0500, Rick Curtis wrote:
> > > >
> > > > > Should your UUID class have an embeddable annotation also?
> > > > >
> > > > > On Thu, Jul 7, 2011 at 4:27 PM, Matthew Goodson
> > > > > <matt...@spidertracks.co.nz>wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > Kevin: We're using maven and it is picking up the Phone_ class
> and
> > > > > > generating the warning
> > > > > >
> > > > > > here's the link for the uuid class that we're using
> > > > > >
> > > > > >
> > > >
> >
> https://github.com/stephenc/eaio-uuid/blob/master/src/main/java/com/eaio/uuid/UUID.java
> > > > > >
> > > > > > And the persistence xml...
> > > > > >
> > > > > > <persistence xmlns="http://java.sun.com/xml/ns/persistence";
> > > > > >  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > > > > >  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> > > > > > http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd";
> > > > > >  version="2.0">
> > > > > >  <persistence-unit name="openjpa">
> > > > > >
> > > > > >
> > > >
> >
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> > > > > >
> > > > > >
> > > > > >    <!-- base package -->
> > > > > >    <class>com.spidertracks.aviator.model.Persistable</class>
> > > > > >    <class>com.spidertracks.aviator.model.UuidEntity</class>
> > > > > >
> > > > > >
> > > > > >    <!-- cluster -->
> > > > > >
> >  <class>com.spidertracks.aviator.model.cluster.ClusterRegion</class>
> > > > > >
> >  <class>com.spidertracks.aviator.model.cluster.SpiderRegion</class>
> > > > > >
> > > > > >    <!-- security -->
> > > > > >
> > > > > >
> > > > > >
> > > >
> >
> <class>com.spidertracks.aviator.model.security.AviatorRememberMeToken</class>
> > > > > >
> > > > > >    <!-- sms -->
> > > > > >
> > > >
> >  <class>com.spidertracks.aviator.model.sms.PhoneValidationMessage</class>
> > > > > >
> >  <class>com.spidertracks.aviator.model.sms.ReceivedSmsMessage</class>
> > > > > >
>  <class>com.spidertracks.aviator.model.sms.SentSmsMessage</class>
> > > > > >    <class>com.spidertracks.aviator.model.sms.SmsMessage</class>
> > > > > >
> >  <class>com.spidertracks.aviator.model.sms.SosClosedMessage</class>
> > > > > >
> > > > > >
> > > >
> >
> <class>com.spidertracks.aviator.model.sms.SosInvalidResponseMessage</class>
> > > > > >    <class>com.spidertracks.aviator.model.sms.SosMessage</class>
> > > > > >
> >  <class>com.spidertracks.aviator.model.sms.SosTierOneMessage</class>
> > > > > >
> > > > > >
> > > > > >
> > > >
> >
> <class>com.spidertracks.aviator.model.sms.SosTierOneReopenedUserMessage</class>
> > > > > >
> >  <class>com.spidertracks.aviator.model.sms.SosTierTwoMessage</class>
> > > > > >
> > > > > >
> > > > > >
> > > >
> >
> <class>com.spidertracks.aviator.model.sms.SosTierTwoReopenedUserMessage</class>
> > > > > >
> > > >
> >  <class>com.spidertracks.aviator.model.sms.SosTierTwoUserMessage</class>
> > > > > >
> > > > > >
> > > > > >    <!-- Sos -->
> > > > > >
> >  <class>com.spidertracks.aviator.model.sos.ContactedPerson</class>
> > > > > >    <class>com.spidertracks.aviator.model.sos.OpenHistory</class>
> > > > > >    <class>com.spidertracks.aviator.model.sos.SoS</class>
> > > > > >
> > > > > >    <!-- spider -->
> > > > > >    <class>com.spidertracks.aviator.model.spider.Spider</class>
> > > > > >
> > > > > >    <!-- message -->
> > > > > >
> > > > > >
> > > > > >
> > > >
> >
> <class>com.spidertracks.aviator.model.spider.message.AlertAcknowlege</class>
> > > > > >
> > > > > >
> > > > > >
> > > >
> >
> <class>com.spidertracks.aviator.model.spider.message.ConfigMessageUpdate</class>
> > > > > >
> > > > > >
> > > > > >
> > > >
> >
> <class>com.spidertracks.aviator.model.spider.message.DistanceSettings</class>
> > > > > >
> > > > > >
> > > > > >
> > > >
> >
> <class>com.spidertracks.aviator.model.spider.message.MobileTerminatedConfirmation</class>
> > > > > >
> > > > > >
> > > >
> > <class>com.spidertracks.aviator.model.spider.message.SpiderUpdate</class>
> > > > > >
> > > > > >
> > > > > >
> > > >
> >
> <class>com.spidertracks.aviator.model.spider.message.SpiderwatchSettings</class>
> > > > > >
> > > > > >
> > > > > >
> > > >
> >
> <class>com.spidertracks.aviator.model.spider.message.TimeDistanceSettings</class>
> > > > > >
> > > > > >
> > > >
> > <class>com.spidertracks.aviator.model.spider.message.TimeSettings</class>
> > > > > >
> > > >
>  <class>com.spidertracks.aviator.model.spider.message.WatchOff</class>
> > > > > >
> >  <class>com.spidertracks.aviator.model.spider.message.WatchOn</class>
> > > > > >
> > > > > >
> > > > > >    <!-- user -->
> > > > > >    <class>com.spidertracks.aviator.model.user.ContactLink</class>
> > > > > >    <class>com.spidertracks.aviator.model.user.Address</class>
> > > > > >    <class>com.spidertracks.aviator.model.user.Customer</class>
> > > > > >
> > > > > >
> > > >
> > <class>com.spidertracks.aviator.model.user.EmailConfirmationToken</class>
> > > > > >
> >  <class>com.spidertracks.aviator.model.user.HashedUserToken</class>
> > > > > >
>  <class>com.spidertracks.aviator.model.user.InvitedPerson</class>
> > > > > >
> > > >
>  <class>com.spidertracks.aviator.model.user.PasswordResetToken</class>
> > > > > >    <class>com.spidertracks.aviator.model.user.Person</class>
> > > > > >    <class>com.spidertracks.aviator.model.user.User</class>
> > > > > >    <class>com.spidertracks.aviator.model.user.Vehicle</class>
> > > > > >    <class>com.spidertracks.aviator.model.user.Phone</class>
> > > > > >
> > > > > >    <properties>
> > > > > >      <property name="me.prettyprint.hom.classpathPrefix"
> > > > > >        value="com.datastax.hectorjpa.bean" />
> > > > > >      <property name="me.prettyprint.hom.keyspace"
> > value="TestKeyspace"
> > > > />
> > > > > >      <property name="me.prettyprint.hom.clusterName"
> > value="TestPool"
> > > > />
> > > > > >      <property name="me.prettyprint.hom.hostList"
> > > > value="localhost:9161" />
> > > > > >      <property name="openjpa.BrokerFactory" value="abstractstore"
> > />
> > > > > >
> > > > > >      <property name="openjpa.abstractstore.AbstractStoreManager"
> > > > > >        value="com.datastax.hectorjpa.store.CassandraStoreManager"
> > />
> > > > > >      <property name="openjpa.MetaDataRepository"
> > > > > >
> >  value="com.datastax.hectorjpa.store.CassandraMetaDataRepository"
> > > > />
> > > > > >
> > > > > >      <property name="openjpa.Optimistic" value="false" />
> > > > > >      <property name="openjpa.LockManager" value="none" />
> > > > > >      <property name="openjpa.ConnectionURL"
> value="localhost:9161"
> > />
> > > > > >      <!-- explicitly disable runtime enhancement support. It
> breaks
> > a
> > > > lot
> > > > > >        of proxy functionality needed for indexing -->
> > > > > >      <property name="openjpa.RuntimeUnenhancedClasses"
> > > > value="unsupported"
> > > > > > />
> > > > > >
> > > > > >       <property name="openjpa.DetachState"
> > > > > >  value="all(DetachedStateField=true)"/>
> > > > > >
> > > > > >      <!-- Used to test the serialization property. If not set
> will
> > > > default
> > > > > >        to java default serialization -->
> > > > > >      <property name="com.datastax.jpa.embeddedserializer"
> > > > > >        value="com.datastax.hectorjpa.serialize.XStreamSerializer"
> > />
> > > > > >      <property name="openjpa.EntityManagerFactory"
> > > > > >        value="me.prettyprint.hom.EntityManagerFactoryImpl" />
> > > > > >
> > > > > >    </properties>
> > > > > >  </persistence-unit>
> > > > > >
> > > > > > </persistence>
> > > > > >
> > > > > >
> > > > > > On Fri, Jul 8, 2011 at 3:36 AM, Kevin Sutter <kwsut...@gmail.com
> >
> > > > wrote:
> > > > > >
> > > > > > > Why are we attempting to enhance a generated metamodel class?
> > > > > > >
> > > > > > > "class com.spidertracks.aviator.model.user.Phone_"
> > > > > > >
> > > > > > > Classes that end in an underscore were probably generated for
> the
> > > > > > metamodel
> > > > > > > and/or criteria API usage.  So, something seems out of whack
> with
> > > > > > > attempting
> > > > > > > to enhance these classes.
> > > > > > >
> > > > > > > Kevin
> > > > > > >
> > > > > > > On Thu, Jul 7, 2011 at 7:53 AM, Rick Curtis <
> curti...@gmail.com>
> > > > wrote:
> > > > > > >
> > > > > > > > Can you post your UUID class and the contents of your
> > > > persistence.xml?
> > > > > > > >
> > > > > > > > Thanks,
> > > > > > > > Rick
> > > > > > > >
> > > > > > > > On Wed, Jul 6, 2011 at 11:09 PM, Matthew Goodson <
> > > > > > > > matt...@spidertracks.co.nz
> > > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > Just adding the class for reference
> > > > > > > > >
> > > > > > > > > @Embeddable
> > > > > > > > > //public class Phone extends EmbeddedUUID implements
> > > > WebOptionString,
> > > > > > > > > Serializable {
> > > > > > > > > public class Phone implements WebOptionString, Serializable
> {
> > > > > > > > >
> > > > > > > > > private static final long serialVersionUID = 1L;
> > > > > > > > >
> > > > > > > > >  @Persistent
> > > > > > > > > private UUID id;
> > > > > > > > >  @Persistent
> > > > > > > > > @NotEmpty(message = "{phone.number.required}")
> > > > > > > > > @NumericString(message = "{phone.number.digitsonly}")
> > > > > > > > > private String number;
> > > > > > > > >
> > > > > > > > > @Persistent
> > > > > > > > > private String countryIdd;
> > > > > > > > >
> > > > > > > > > @Persistent
> > > > > > > > > @NotNull(message = "{phone.country.required}")
> > > > > > > > > private String iddCountryCode;
> > > > > > > > >
> > > > > > > > > @Persistent
> > > > > > > > > @NotNull(message = "{phone.type.required}")
> > > > > > > > > private PhoneType type;
> > > > > > > > >
> > > > > > > > > public Phone() {
> > > > > > > > > id = new UUID();
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > public Phone(String number, Country country, PhoneType
> type)
> > {
> > > > > > > > > this();
> > > > > > > > > this.number = number;
> > > > > > > > > this.type = type;
> > > > > > > > > setIddCountry(country);
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > public void setNumber(String number) {
> > > > > > > > > this.number = number;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > public String getNumber() {
> > > > > > > > > return number;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > public void setType(PhoneType type) {
> > > > > > > > > this.type = type;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > public PhoneType getType() {
> > > > > > > > > return type;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > @Override
> > > > > > > > > public String getDisplayString() {
> > > > > > > > > return number;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > public void setIddCountry(Country country) {
> > > > > > > > > if (country != null) {
> > > > > > > > > this.iddCountryCode = country.getCode();
> > > > > > > > > this.countryIdd = country.getIdd();
> > > > > > > > > }
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > public Country getIddCountry() {
> > > > > > > > > if (iddCountryCode != null) {
> > > > > > > > > return
> > CountryFactory.INSTANCE.getByCode(this.iddCountryCode);
> > > > > > > > > }
> > > > > > > > > return null;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > public String getIddCountryCode() {
> > > > > > > > > return iddCountryCode;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > public String getFullNumber() {
> > > > > > > > > return (countryIdd == null ? "" : countryIdd) + (number ==
> > null ?
> > > > ""
> > > > > > :
> > > > > > > > > number);
> > > > > > > > > }
> > > > > > > > >  public void clone(Phone other) {
> > > > > > > > > Assert.notNull(other);
> > > > > > > > > setIddCountry(other.getIddCountry());
> > > > > > > > > setNumber(other.getNumber());
> > > > > > > > > setType(other.getType());
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > public UUID getId() {
> > > > > > > > > return id;
> > > > > > > > > }
> > > > > > > > >  public void setId(UUID id) {
> > > > > > > > > Assert.notNull(id);
> > > > > > > > >  this.id = id;
> > > > > > > > > }
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On Thu, Jul 7, 2011 at 3:36 PM, Matthew Goodson
> > > > > > > > > <matt...@spidertracks.co.nz>wrote:
> > > > > > > > >
> > > > > > > > > > Hi guys. I have a problem with jpa enhancement.
> > > > > > > > > > I am using version 2.1.0 and I am trying to get it to
> > enhanced
> > > > an
> > > > > > > > object
> > > > > > > > > > 'Phone' with a field 'id' which is of type com.eaio.UUID.
> > > > However
> > > > > > > when
> > > > > > > > I
> > > > > > > > > run
> > > > > > > > > > the enhancement I get the 2 warnings below.
> > > > > > > > > > Any ideas?
> > > > > > > > > >
> > > > > > > > > > 411  openjpa  WARN   [main] openjpa.MetaData - Field "
> > > > > > > > > > com.spidertracks.aviator.model.user.Phone.id" is not a
> > type
> > > > that
> > > > > > is
> > > > > > > > > > persistent by default.  If you want this field to be
> > > > persistent,
> > > > > > you
> > > > > > > > have
> > > > > > > > > to
> > > > > > > > > > explicitly set it to persistent in your metadata.
> > > > > > > > > >
> > > > > > > > > > 681  openjpa  WARN   [main] openjpa.Enhance - Type "class
> > > > > > > > > > com.spidertracks.aviator.model.user.Phone_" loaded by
> > > > > > > > > > java.net.URLClassLoader@69dfe453 has no metadata;
> > enhancing as
> > > > > > > > > persistence
> > > > > > > > > > aware. If you intended for "class
> > > > > > > > > > com.spidertracks.aviator.model.user.Phone_" to be
> > > > > > > persistence-capable,
> > > > > > > > > then
> > > > > > > > > > this means that OpenJPA could not find any metadata for
> > "class
> > > > > > > > > > com.spidertracks.aviator.model.user.Phone_". This can
> > happen if
> > > > the
> > > > > > > > > > directory containing your metadata is not in your
> > CLASSPATH, or
> > > > if
> > > > > > > your
> > > > > > > > > > metadata files are not named properly. See the
> > documentation on
> > > > > > > > metadata
> > > > > > > > > > placement for more information.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > *Rick Curtis*
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> > > > > > Matthew
> > > > > >
> > > > > > Software Engineer
> > > > > >
> > > > > > Matthew Goodson | spidertracks
> > > > > >
> > > > > > po box 5203 | 117a the square | Palmerston North 4441 | new
> zealand
> > > > > >
> > > > > > P: +64 6 353 3395 | M: +64 27 6969639
> > > > > >
> > > > > > E: *matt...@spidertracks.co.nz* <matt...@spidertracks.co.nz>   *
> > > > > > www.spidertracks.com*
> > > > > >
> > > > > > spiderwatch - because in the rescue game, time = life.
> > > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> > >
> >
>
>
>
> --
> *Rick Curtis*
>



-- 

Matthew

Software Engineer

Matthew Goodson | spidertracks

po box 5203 | 117a the square | Palmerston North 4441 | new zealand

P: +64 6 353 3395 | M: +64 27 6969639

E: *matt...@spidertracks.co.nz* <matt...@spidertracks.co.nz>   *
www.spidertracks.com*

spiderwatch - because in the rescue game, time = life.

Reply via email to