Hi Vasiliy. I guess this code will helpfull for you.
public WTDocument getWTDocByNumber(String number)
{
WTDocument wtd = new WTDocument();
WTDocumentMaster wtdm = null;
try
{
QuerySpec qs = new QuerySpec(WTDocumentMaster.class);
qs.appendWhere(new SearchCondition(WTDocumentMaster.class, "number", "=", number), 0);
QueryResult find = PersistenceHelper.manager.find(qs);
if (find.hasMoreElements())
{
wtdm = (WTDocumentMaster)find.nextElement();
}
try {
wtd.setMaster((Mastered)wtdm);
} catch (WTPropertyVetoException ex) {System.out.println(ex);}
}
catch (WTException ex)
{
ex.printStackTrace();
}
return wtd;
}