# Privates Attribut in einer JPA Entitiy Class ohne DB-Spalte?



## t3_chris (21. Feb 2008)

Hallo!

Ich brauche in meiner JPA/TopLink Entity Class ein privates Attribut welches nicht in die DB persistiert werden soll.
Konkret handelt es sich um ein PropertyChangeSupport Objekt.

Leider funktioniert das aber nicht so wie ich das gerne hätte. Ich bekomme beim speichern in die DB folgende Exception.

Welche Annotation muss ich verwenden, damit propertyChangeSpt nicht als DB-Spalte angesehen wird?

Danke schon mal im Voraus für Eure Anregungen!


```
[TopLink Warning]: 2008.02.21 09:04:13.593--UnitOfWork(16747636)--Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'PROPERTYCHANGESPT' in 'field list'
Error Code: 1054
Call: INSERT INTO credentials (user, password, url, memo, name, PROPERTYCHANGESPT) VALUES (?, ?, ?, ?, ?, ?)
        bind => [pwd, pd, url, null, name, [B@ff94b1]
Query: InsertObjectQuery(at.percom.internal.Credentials[credentialId=null])
Exception in thread "AWT-EventQueue-0" javax.persistence.RollbackException: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'PROPERTYCHANGESPT' in 'field list'
Error Code: 1054
Call: INSERT INTO credentials (user, password, url, memo, name, PROPERTYCHANGESPT) VALUES (?, ?, ?, ?, ?, ?)
        bind => [pwd, pd, url, null, name, [B@ff94b1]
Query: InsertObjectQuery(at.percom.internal.Credentials[credentialId=null])
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:120)
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:60)
        at at.percom.passwords.gui.StartFrame.btnSaveActionPerformed(StartFrame.java:248)
        at at.percom.passwords.gui.StartFrame.access$100(StartFrame.java:20)
        at at.percom.passwords.gui.StartFrame$2.actionPerformed(StartFrame.java:117)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:6041)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
        at java.awt.Component.processEvent(Component.java:5806)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4413)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
        at java.awt.Container.dispatchEventImpl(Container.java:2102)
        at java.awt.Window.dispatchEventImpl(Window.java:2440)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'PROPERTYCHANGESPT' in 'field list'
Error Code: 1054
```


Hier ist meine Klasse:


```
package at.percom.passwords.corelogic;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.GenerationType;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;


@Entity
@Table(name = "credentials")
@NamedQueries({@NamedQuery(name = "Credential.findByCredentialId", query = "SELECT c FROM Credential c WHERE c.credentialId = :credentialId"), @NamedQuery(name = "Credential.findByName", query = "SELECT c FROM Credential c WHERE c.name = :name"), @NamedQuery(name = "Credential.findByUrl", query = "SELECT c FROM Credential c WHERE c.url = :url"), @NamedQuery(name = "Credential.findByUser", query = "SELECT c FROM Credential c WHERE c.user = :user"), @NamedQuery(name = "Credential.findByPassword", query = "SELECT c FROM Credential c WHERE c.password = :password")})
public class Credential implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "credential_id", nullable = false)
    private Integer credentialId;
    
    @Column(name = "name", nullable = false)
    private String name;
    
    @Column(name = "url", nullable = false)
    private String url;
    
    @Column(name = "user", nullable = false)
    private String user;
    
    @Column(name = "password", nullable = false)
    private String password;
    
    @Lob
    @Column(name = "memo")
    private String memo;
    
    private PropertyChangeSupport propertyChangeSpt = new PropertyChangeSupport(this);

    .... usw.
```


----------



## byte (21. Feb 2008)

@Transient


----------



## t3_chris (21. Feb 2008)

Perfekt, danke. War aber nicht @Transient sondern

transient private Typ nameDesObjekts;

Danke Trotzdem!


----------



## byte (21. Feb 2008)

Bei Hibernate ist es @Transient. Müsste eigtl JPA-konform sein, dachte ich zumindest.


----------

