代码之家  ›  专栏  ›  技术社区  ›  Tamer Saleh

云SQL第二代问题

  •  1
  • Tamer Saleh  · 技术社区  · 6 年前

    我正在运行一个Java Web应用程序 App engine standard environment 使用此配置

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

    并连接到云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,在我完成这项工作并将更改部署到app engine中之后,它运行得很好,但30分钟后,它开始抛出下面的错误,我将版本设置回原来的版本,然后异常消失了2个月,今天n我将云SQL秒生成的默认时区从“+02:00”更改为“+01:00”,然后重新启动我的数据库它工作了10分钟,然后开始抛出相同的异常

    异常详细信息

    任何jpa查询都会抛出它 示例:“从用户u中选择u,其中u.facebook id=: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 = ?)")
    

    用户类是

    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 回复  |  直到 6 年前
        1
  •  0
  •   Tamer Saleh    6 年前

    我修复了它,看起来像是从2.7.1版开始的eclipse链接,mysql db有这个问题,而且它不稳定,我刚刚把它降级到2.7.0,现在它运行得很好。