AnnotationException: A Foreign key refering has the wrong number of column. should be 2

Your class CiudadPK has two columns in it. You’re only using @JoinColumn which is limited to a single column. You need to use @JoinColumns and list out both columns in the FK, e.g. // bi-directional many-to-one association to Provincia @ManyToOne(fetch=FetchType.LAZY) @JoinColumns({ @JoinColumn(name = “codProvincia”, insertable = false, updatable = false), @JoinColumn(name = “codRegion”, insertable = … Read more

Can javascript access a filesystem? [duplicate]

Tiddlywiki has several methods of saving data, depending on which browser is used. As you could see in the source. If ActiveX is enabled, it uses Scripting.FileSystemObject. On Gecko-based browsers, it tries to use UniversalXPConnect. If Java is enabled, it uses the TiddlySaver Java applet. If Java LiveConnect is enabled, it tries to use Java’s … Read more

How to insert images in mongoDB using java?

For storing binary data like images you can use GridFS or implement your own realization; Download the driver and look at src/test/com/mongodb/gridfs/GridFSTest.java 😉 Edit: you are lucky today! I made complete code for you;) Enjoy! package mongodb.testing.java; import com.mongodb.*; import com.mongodb.gridfs.*; import java.io.*; public class Main { public static byte[] LoadImage(String filePath) throws Exception { … Read more

Make persistent changes to init.rc

Unpack the uramdisk using following command in host PC(Linux) mkdir /tmp/initrc cd /tmp/initrd sudo mount /dev/sdb1 /mnt sdb1 is partion where uramdisk/uInitrd resides. dd bs=1 skip=64 if=/mnt/uInitrd of=initrd.gz gunzip initrd.gz At this point running the command file initrd should show: mkdir fs cd fs cpio -id < ../initrd Make changes to init.rc Pack uramdisk using … Read more

Java Persistence: Cast to something the result of Query.getResultList()?

As a newcomer to JPA was taking this as the definitive answer but then I found a better one via this question: Why in JPA EntityManager queries throw NoResultException but find does not? Its as simple as as using TypedQuery instead of Query e.g.: TypedQuery<Person> lQuery = myEntityManager.createQuery(“from Person”, Person.class); List<Person> personList = lQuery.getResultList();