2016-11-25 7 views
0

私は休止状態にするのが初めてです。私は以下のエンティティをマップしようとしていますが、ハイバネートマッピング例外を取得しています。ヘルプは非常に高く評価されます。 はIAMのは、PostgreSQLpostgresqlでのHibernateマッピングの問題

package st.malike.auth.server.model; 

import java.io.Serializable; 
import javax.persistence.Entity; 
import javax.persistence.GeneratedValue; 
import javax.persistence.GenerationType; 
import org.springframework.security.oauth2.common.OAuth2RefreshToken; 
import org.springframework.security.oauth2.provider.OAuth2Authentication; 


@Entity 
public class OAuth2AuthenticationRefreshToken implements Serializable { 

// @Indexed 
    @javax.persistence.Id 
    @GeneratedValue(strategy = GenerationType.IDENTITY) 
    private String id; 
    private final String tokenId; 
    private final OAuth2RefreshToken oAuth2RefreshToken; 
    private final OAuth2Authentication authentication; 

    public OAuth2AuthenticationRefreshToken(OAuth2RefreshToken oAuth2RefreshToken, OAuth2Authentication authentication) { 
     this.oAuth2RefreshToken = oAuth2RefreshToken; 
     this.authentication = authentication; 
     this.tokenId = oAuth2RefreshToken.getValue(); 
    } 

    public String getId() { 
     return id; 
    } 

    public void setId(String id) { 
     this.id = id; 
    } 

    public String getTokenId() { 
     return tokenId; 
    } 

    public OAuth2RefreshToken getoAuth2RefreshToken() { 
     return oAuth2RefreshToken; 
    } 

    public OAuth2Authentication getAuthentication() { 
     return authentication; 
    } 
} 

を使用して、データベースとのすべてのマッピングを無視するように注釈@Transientを追加し、属性oAuth2RefreshTokenのための任意の値を保存していない場合

Caused by: org.hibernate.MappingException: Could not determine type for: org.springframework.security.oauth2.common.OAuth2RefreshToken, 
    at table: oauth2authentication_refresh_token, 
    for columns: [org.hibernate.mapping.Column(o_auth2refresh_token)]  
    at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:396) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final] 
    at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:369) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final] 
    at org.hibernate.mapping.Property.isValid(Property.java:225) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final] 
    at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final] 
    at org.hibernate.mapping.RootClass.validate(RootClass.java:265) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final] 
    at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final] 
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:443) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final] 
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.9.Final.jar:5.0.9.Final] 
    ... 162 common frames omitted 
+0

に追加してくださいあまりにも – Zulfi

+0

をあなたのテーブルのスキーマを提供してください、あなたのデータベースにすべてのフィールドの値を保存するつもりですか?特にフィールド 'oAuth2RefreshToken'と' authentication'は、それらをデータベースに格納しますか? '@ Transient'でアノテーションを付けないか、修飾子' transient'をその宣言に追加しない場合 –

+0

@Zulfiの設定はspring.datasource.url = jdbc:postgresql:// localhost:5432/eCoreAS spring.datasource.username = postgres です。 spring.datasource.password = postgre spring.datasource.driverクラス名= org.postgresql.Driver spring.datasource.maxActive = 10 spring.datasource.maxIdle = 5 spring.datasource.minIdle = 2 スプリング。 datasource.initialSize = 5 spring.datasource.removeAbandoned =真 spring.jpa.databaseプラットフォーム= org.hibernate.dialect.PostgreSQLDialect spring.jpa.generate-DDL =真 spring.jpa.show-SQL = TR ue spring.jpa.hibernate.ddl-auto = create – Farhan

答えて

2

以下のように例外を取得し、覚えておいてください。

あなたには、いくつかのマッピングを持っている場合は、あなたの質問