Oracle: sequence MySequence.currval is not yet defined in this session

mysequence.CURRVAL returns the latest value that was obtained from sequence mysequence in your session, and hence isn’t defined until you have obtained a value using mysequence.NEXTVAL at least once in the session. The purpose of CURRVAL is to let you use the sequence value more than once in your code e.g. insert into parent (parent_id, … Read more

When to use forEach(_:) instead of for in?

There is no performance benefit offered by forEach. In fact, if you look at the source code, the forEach function actually simply performing for–in. For release builds, the performance overhead of this function over simply using for–in yourself is immaterial, though for debug builds, it results in an observable performance impact. The main advantage of … Read more

Sequential Guid Generator

You could just use the same Win32 API function that SQL Server uses: UuidCreateSequential and apply some bit-shifting to put the values into big-endian order. And since you want it in C#: private class NativeMethods { [DllImport(“rpcrt4.dll”, SetLastError=true)] public static extern int UuidCreateSequential(out Guid guid); } public static Guid NewSequentialID() { //Code is released into … Read more

How does the JPA @SequenceGenerator annotation work

sequenceName is the name of the sequence in the DB. This is how you specify a sequence that already exists in the DB. If you go this route, you have to specify the allocationSize which needs to be the same value that the DB sequence uses as its “auto increment”. Usage: @GeneratedValue(generator=”my_seq”) @SequenceGenerator(name=”my_seq”,sequenceName=”MY_SEQ”, allocationSize=1) If … Read more

Scala: Remove duplicates in list of objects

list.groupBy(_.property).map(_._2.head) Explanation: The groupBy method accepts a function that converts an element to a key for grouping. _.property is just shorthand for elem: Object => elem.property (the compiler generates a unique name, something like x$1). So now we have a map Map[Property, List[Object]]. A Map[K,V] extends Traversable[(K,V)]. So it can be traversed like a list, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)