Cloud Sql第二代问题

时间:2018-11-21 17:39:16

标签: google-app-engine eclipselink google-cloud-sql

我的Java Web应用程序在App engine standard environment中以这种配置运行

 <basic-scaling>
    <max-instances>25</max-instances>
    <idle-timeout>50m</idle-timeout>
  </basic-scaling>

并连接到第二代Cloud Sql:

vCPUs  Memory     SSD Storage 
2        7.5GB       31GB 

和Im使用具有以下版本的Eclipse链接提供程序

<dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        <version>2.1.1</version>
    </dependency>

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.7.1</version>
        <exclusions>
        <exclusion>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        </exclusion>
        </exclusions>           
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.12</version>
                <exclusions>
                <exclusion>
                <groupId>com.google.protobuf</groupId>
                <artifactId>protobuf-java</artifactId>
                </exclusion>
                </exclusions>           

    </dependency>

我把这些排除项放到了一起,导致它与POM.xml中使用的其他库im发生冲突。

一切都很好,后来我将eclipse链接的版本升级为2.7.3,并将更改部署到应用程序引擎中可以正常工作,但30分钟后,它开始抛出以下内容错误,我将版本设置回了,该异常仅持续了2个月,而今天,当我将云SQL sec生成的default_time_zone从“ +02:00”更改为“ +01:00”时,我重新启动了数据库罚款10分钟,然后开始引发相同的异常

异常详细信息

针对任何JPA查询抛出的     示例:“从用户u中选择u,其中u.facebookId =:fbid”

[e~p8belel/api:20181121t183222.414147041342026241].<stdout>: [EL Warning]: 2018-11-21 17:10:39.183--UnitOfWork(1650244092)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.1.v20171221-bd47e8f): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Column Index out of range, 2 > 1. 
Error Code: 0
Call: SELECT ID, about_me, account_note, account_status, birth_date, body_type, created_time, EMAIL, facebook_access_token_expry, facebook_access_token, facebook_id, game_balance, game_last_time_play, gender, hashed_password, HEIGHT, IP, job_details, last_activity_date, LIKABILITY, NAME, phone_number, signedup_device_id, signup_token, un_serious_count, class, subscription_plan, CITY_ID, marital_status_id, NEIGHBORHOOD_ID, RELIGION_ID, collage_id, job_id, my_match_id, setting_id, univ_id FROM user_table WHERE (facebook_id = ?)
    bind => [1 parameter bound]
Query: ReadAllQuery(name="User.getUserByFbId" referenceClass=User sql="SELECT ID, about_me, account_note, account_status, birth_date, body_type, created_time, EMAIL, facebook_access_token_expry, facebook_access_token, facebook_id, game_balance, game_last_time_play, gender, hashed_password, HEIGHT, IP, job_details, last_activity_date, LIKABILITY, NAME, phone_number, signedup_device_id, signup_token, un_serious_count, class, subscription_plan, CITY_ID, marital_status_id, NEIGHBORHOOD_ID, RELIGION_ID, collage_id, job_id, my_match_id, setting_id, univ_id FROM user_table WHERE (facebook_id = ?)")

User类是

public class User {




@Id
    String id;


    @Column(nullable = false)
    String name;

    @Column(unique = true)
    String email;

    @Column(name="phone_number",unique = true)
    @Convert(converter = EncryptorConverter.class)
    String phoneNumber;

    @Column(name="hashed_password")
    String hashedPassword;

    @Column(name="signedup_device_id", unique=true)
    String signedUpDeviceId;

    @Column(name="signup_token")
    String signupToken; 

    @OneToOne(mappedBy = "user")
    private VerificationId verificationId;

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "setting_id")
    AccountSetting setting = new AccountSetting();

    @Temporal(TemporalType.DATE)
    @Column(name = "birth_date")
    Date birthDate;

    @ManyToOne
    @JoinColumn(name="marital_status_id")
    MaritalStatus maritalStatus;

    @Enumerated(EnumType.STRING)
    @Column(name = "account_status")
    AccountStatus accountStatus;

    @OneToMany(mappedBy = "user")
    List<Device> devices;

    @Deprecated
    @ManyToOne
    City city;

    @ManyToOne  
    Neighborhood neighborhood;

    Integer height;

    @Column(name="body_type")
    @Enumerated(EnumType.STRING)
    BodyType bodyType;

    @Column(name="game_balance")
    Integer gameBalance = 0;

    @ManyToOne
    Religion religion;

    @JoinColumn(name = "my_match_id")
    User myMatch;

    Integer likability;

    @Column(name="un_serious_count")
    Integer unSeriousCount;

     @Temporal(TemporalType.TIMESTAMP)
     @Column(name = "game_last_time_play")             
     Date gameLastPlay;


    @Lob
    @Column(name = "job_details")
    @Convert(converter = EncryptorConverter.class)
    String jobDetails;

    @JoinColumn(name = "job_id")
    Job job;

    @JoinColumn(name = "univ_id")
    University university;

    @JoinColumn(name = "collage_id")
    Collage collage;

    @Lob
    @Column(name = "about_me")
    @Convert(converter = EncryptorConverter.class)
    String aboutMe;

    @Lob
    @Column(name = "account_note")
    @Convert(converter = EncryptorConverter.class)
    String accountNote;

    @Lob
    @Convert(converter = EncryptorConverter.class)
    @Column(name = "facebook_access_token", length = 700)
    String facebookAccessToken;

    @Column(name = "facebook_access_token_expry")
    @Temporal(TemporalType.DATE)
    Date faceBookTokenExpry;

    @Column(name = "facebook_id", unique = true)
    String facebookId;

    @Column(name = "gender")
    @Enumerated(EnumType.STRING)
    Gender gender;

    @Column(name = "class")
    @Enumerated(EnumType.STRING)
    UserClass userClass;

    @OneToMany(mappedBy = "user")
    @OrderBy("pictureOrder")
    List<Picture> pictures = new ArrayList<Picture>(); 

    @OneToMany(mappedBy = "user")
    List<UserAnswer> answers;

    @OneToMany(mappedBy = "user", orphanRemoval = true)
    List<WorkHistory> work = new ArrayList<>();

    @OneToMany(mappedBy = "user", orphanRemoval = true)
    List<EducationHistory> education = new ArrayList<>();

    @Column(name = "last_activity_date")
    @Temporal(TemporalType.DATE)
    Date lastActivityDate = new Date();

    @Enumerated(EnumType.STRING)
    @Column(name="subscription_plan")
    SubscriptionPlan userPlan = SubscriptionPlan.FREEMIUM;

// getters and setters

}

对于这么大的帖子,我感到非常抱歉,但是我真的没想到为什么会发生这种异常

1 个答案:

答案 0 :(得分:0)

我已修复它,似乎从2.7.1版开始的eclipse链接存在MYSQL DB的问题,并且不稳定,我只是将其降级到2.7.0,现在它可以正常工作