如何在一个查询中向数据库提交两个数据

时间:2014-02-20 13:29:12

标签: java jpa

我能够将组合框中的值保存到我的数据库中的相关列,但我现在要做的是将数据添加到同一查询中同一个表中的另一列,但我不确定如何构建查询

我试图包含的数据是studentNumber,它是一个已经在辅助bean中分配了静态值的变量:

//For testing untill other memebers get some code working, on which i require
private int studentNumber = 500198;

我当前向数据库添加数据的方式是:

<p:spinner id="ajaxspinner80-100"
    value="#{markingBean.markSectionOne.markSectionOne}" stepFactor="1"
    min="80" max="100" disabled="#{formBean.number != 8}">
    <p:ajax update="ajaxspinnervalue" process="@this" />
</p:spinner>

用户从微调器中选择一个值:

<p:commandButton action="#{markingBean.markSectionOne}" value="#{bundle.buttonSave}" update=":growl" icon="ui-icon-disk"/>

按save并转到markerController:

中的此代码
public String markSectionOne() {
    //supposing the data in markSectionOne is filled...
    this.markingFacade.create(markSectionOne);
    this.setMessage("Mark Saved");
    //after saving...
    markSectionOne = new Marking();
    // now navigating to the next page
    return "/lecturer/marking/marking-section-two"; 
} 

将其保存到数据库。

我现在想在同一查询中添加学号以将studentNumber保存到DB中的studentNumber列

修改

这是我的标记表实体类

@Entity(name = "MARKING")
public class Marking implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private String studentNumber,markingStage, markingCompleted, markSectionOne, markSectionTwo, markSectionThree, markSectionFour, markSectionFive, overalMark, plagorism, feedback, comments;

0 个答案:

没有答案