简体   繁体   中英

Cannot SELECT data from oracle table with hibernate

I created a simple spring mvc web app with hibernate and mysql (Everything worked well). Then, I changed mysql to oracle . After first run of the application, (connected to oracle database) tables, corresponding to the entity models defined in my application, were created. I added one country and one user to COUNTRY and MYAPPUSER tables from SQL DEVELOPER . Now, I am trying to get a user from MYAPPUSER table but I am getting null instead of user, which exists.

This is User entity:

@Entity
@Table(name = "myAppUser")
public class User {

    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "id_Sequence")
    @SequenceGenerator(name = "id_Sequence", sequenceName = "ID_SEQ")
    @Column(name = "Id", updatable = false, nullable = false)
    private int id;

    @Column(name = "FirstName")
    private String firstName;

    @Column(name = "LastName")
    private String lastName;

    @Column(name = "Username")
    private String username;

    @Column(name = "Password")
    private String password;

    @OneToMany(mappedBy = "user")
    private List<UserSubject> userSubjects;

    @ManyToOne
    @JoinColumn(name = "country_id", nullable = false)
    private Country country;

    @OneToMany(mappedBy = "user")
    private List<Test> testList;

    //and getters and setters

}

This is code while debugging:

在此处输入图片说明

In sql developer:

在此处输入图片说明

this is generated sql by hibernate:

在此处输入图片说明

I am interested in why user is null after selecting data and why question marks are in place of user1 and 123 in generated sql?

I think this effect is specific to oracle, because I had not such problem with MySQL database.

PS Exceptions aren't thrown....

根据评论,解决方案是在SQL Developer中提交。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM