DAO中的外键与Java

时间:2015-11-28 01:17:04

标签: java mysql database foreign-keys dao

我知道这是一个非常愚蠢的问题,但我无法在任何地方找到它。如果我在数据库中有两个表,如:

Rows

当我需要把它放在java中来制作DAO时。雇主班到底怎么样?类似的东西:

Rem Set CheckBoxes Placement Property
For Each ChkBox In ActiveSheet.CheckBoxes
    ChkBox.Placement = xlMove
Next

Rem Set CheckBoxes Rows
For Each ChkBox In ActiveSheet.CheckBoxes

    Rem Set CheckBox Row
    'Set rRow = Range(ChkBox.TopLeftCell, ChkBox.BottomRightCell).EntireRow
    Set rRow = ChkBox.TopLeftCell.EntireRow
    rRow.Select: Stop
    rRow.Interior.Color = RGB(255, 255, 0): Stop

    Rem Join CheckBoxes Rows
    If rRowsDel Is Nothing Then
        Set rRowsDel = rRow
    Else
        Set rRowsDel = Union(rRowsDel, rRow)
    End If

Next

Rem Delete CheckBoxes
For Each ChkBox In ActiveSheet.CheckBoxes
    ChkBox.Delete
Next

Rem Delete CheckBoxes Rows
rRowsDel.Delete

End Sub

        string line;
        int counter = 0;

        Console.WriteLine("Enter a word to search for: ");
        var text = Console.ReadLine();

        string file = "newfile.txt";
        StreamReader myFile = new StreamReader(file);

        Console.WriteLine("\n");

        while ( (line = myFile.ReadLine()) != null )
        {
            if(line.Contains(text))
            {
                break;
            }
            counter++;
        }
        Console.WriteLine("Line number: {0}", counter);

        myFile.Close();
        Console.ReadLine();

我想问的是......我怎么必须放一把外键? java怎么知道两个表之间有关系?最好以最简单的方式,而不使用任何框架来帮助。

1 个答案:

答案 0 :(得分:1)

您可以在员工对象中嵌入薪水对象

public class Employee {
    private int ID;
    private Salary salary;
    ...
    ....
}