Project, use a sequence as a single number, the framework is used by SSH, when the DAO layer to fetch, run times wrong to dual is not mapped,[select *.nextval nextvalue from dual]
Later, the inspection found that the way to get the wrong, so change to the following, you can normally get
//get the last value of a SEQ PublicString findseq () { Try{String SQL= "Select Patient_seq.nextvalNextValueFrom dual "; Integer Maxid= (Integer) ( This. GetSession (). createsqlquery (SQL). Addscalar ("NextValue", Hibernate.integer)). Uniqueresult (); returnmaxid.tostring (); } Catch(Exception e) {e.printstacktrace (); } return NULL; }
If you have integrated Hibernatedaosupport, you can also use the following method:
Public String findseq () { nextvalue from dual ";
return (String) Gethibernatetemplate (). Find (QueryString). Get (0);
}
1. First return to list collection gethibernatetemplate (). Find (QueryString)
2. Get the first element of list: List.get (0);
The result of 3.list.get (*) is ojbect, so either a strong-turn (String) list.get (0), or list.get (0). toString ();
Java gets the last value of sequences in Oracle