-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Any other way to mark a field transient when using EM/JPA?
PostPosted: Fri Jun 19, 2009 1:50 am 
Newbie

Joined: Thu Jun 18, 2009 10:06 pm
Posts: 1
Hi all

We are using hibernate in a JPA setup with hibernate 3.3.1, annotations 3.4.0 and entity manager 3.4.0.

We are attempting to add property change support to our mapped entity classes using aspectj, and aspectj weaves in a new private field to hold the PropertyChangeSupport object. Hibernate then complains because it can't work out how to store the field with an exception looking like:
Code:
Caused by: org.hibernate.MappingException: Could not determine type for: ssabsa.swing.bean.PropertyChangeNotifier$PropertySupport, at table: ORM_Codes, for columns: [org.hibernate.mapping.Column(ajc$instance$ssabsa_swing_bean_PropertyChangeNotifier$ssabsa_swing_bean_PropertyChangeNotifier$PropertySupport)]
   at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:292)
   at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:276)
   at org.hibernate.mapping.Property.isValid(Property.java:207)
   at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:458)
   at org.hibernate.mapping.RootClass.validate(RootClass.java:215)
   at org.hibernate.cfg.Configuration.validate(Configuration.java:1135)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1320)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
   ... 64 more


We obviously don't want that field to be mapped, but have no easy way to hang an @Transient on it. I have tried to add the generated field name to orm.xml as a transient thusly:

Code:
<?xml version="1.0" encoding="UTF-8" ?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
        http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" version="1.0" >
    <entity class="ssabsa.persist.vo.ref.CodeVO" metadata-complete="false">
      <attributes>
        <transient name="ajc$instance$ssabsa_swing_bean_PropertyChangeNotifier$ssabsa_swing_bean_PropertyChangeNotifier$PropertySupport"/>
      </attributes>
    </entity>
</entity-mappings>


but end up getting the same error message, although interestingly I now get this at the top of my log file:

Code:
15:05:04,176  WARN [main] [EJB3OverridenAnnotationReader:395] Property ssabsa.persist.vo.ref.CodeVO.ajc$instance$ssabsa_swing_bean_PropertyChangeNotifier$ssabsa_swing_bean_PropertyChangeNotifier$PropertySupport not found in class but described in <mapping-file/> (possible typo error)


So it seems that one part of the hibernate config doesn't think that it's a property (perhaps because it doesn't have get/set methods?) but the later part does - after ignoring my attempt to mark it as transient. This feels like a bug - if hibernate is going to throw an exception about a field, I should be able to mark it as transient in orm.xml. Whether considered a bug or not, I can't currently do what I want to do here.

Any suggestions on a work-around? I'd prefer not to have to totally switch to property access / config, as it's much more readable to be able to annotate fields rather than getter methods in our entity classes.

Any help much appreciated.

Cheers, Tom


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.