Wednesday, October 9, 2013

operator does not exist: character varying = bytea

Check foreign keys have same type as in main table. In my case main table has character(10) and foreign key character (5).

ERROR: operator does not exist: character varying = bytea
  Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
  Position: 276

Sunday, August 11, 2013

java.io.StreamCorruptedException: invalid stream header: 32303133

If it is associated to "Caused by: org.hibernate.type.SerializationException: could not deserialize", then check the type of the classes you are importing.

I mistakenly was importing:

  • import java.security.Timestamp;

Instead of
  • import java.sql.Timestamp;


Tuesday, July 23, 2013

git stuff

Automatically rebase on your new branches when you pull...
  • git config --global branch.autosetuprebase always

To set rebase when pulling on an existing branch
  • git config branch.master.rebase true
To check what would happen on a branch when you pull.
  • git remote show origin
Check out a remote branch
  • git checkout -b <branch name> origin/<branch name>
Push to a remote branch
  • git push origin <branch name>
Cherry-pick
  • git cherry-pick <commit id>

Saturday, July 20, 2013

Scala break out for / while loops...

Ok, first of all I have to give credit to the following post since it help me to come out with a solution.

http://stackoverflow.com/questions/2742719/how-do-i-break-out-of-a-loop-in-scala

Let say that in java you have something like this:

public boolean validateObject(Answer anObject) {...}

And inside of another method you have a loop that you want to break when validateObject method returns "true". In Java it would looks like:

public void aLoopMethod() {
   boolean temp = false;
   List[Answer] list = methodGetAnswers();
   int index = 0;
   while (temp == false || index < list.size() ) {
      temp = validateObject(list.get(index));
      index++;
   }
}

Translated to Scala it would be something like this:

val temp = false
(0 to list.size).toStream.takeWhile(_ => !temp).foreach(i => (temp = validateObject(uuid,list.get(i))))

Seems to be easy, but it took some hours to figure out the solution. I hope it helps you...




Friday, July 19, 2013

How to add another language to android keyboard...

This works for Android 4.2.2:

Settings -> Language & Input -> Google Keyboard -> Input languages -> Uncheck "Use system language" -> Select all the languages you need...


JAXB Marshaller no threadsafe - Error

I got this error...

java.lang.ArrayIndexOutOfBoundsException: -1
at com.sun.xml.bind.v2.util.CollisionCheckStack.pushNocheck(CollisionCheckStack.java:132)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:491)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:116)

at ....sci.XmlUtil.convertToXml(XmlUtil.java:52)

or this one:

java.lang.NullPointerException
at com.sun.xml.internal.bind.v2.runtime.Coordinator.popCoordinator(Coordinator.java:150)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.close(XMLSerializer.java:847)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:317)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:236)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:116)
at .....XmlUtil.convertToXml(XmlUtil.java:52)

Cause:

Our XML class was sharing Marshaller and Unmarshaller instances among several threads.

Solution:

Create a Marshaller and Unmarshaller per request, as described in this Link