What’s the difference between the name argument in @Entity and @Table when using JPA?

@Table is optional. @Entity is needed for annotating a POJO class as an entity, but the name attribute is not mandatory. If you have a class @Entity class MyEntity {} A table with name “MyEntity” will be created and the Entity name will be MyEntity. Your JPQL query would be: select * from MyEntity In … Read more

When to use DiscriminatorValue annotation in hibernate

These 2 links help me understand the inheritance concept the most: http://docs.oracle.com/javaee/6/tutorial/doc/bnbqn.html http://www.javaworld.com/javaworld/jw-01-2008/jw-01-jpa1.html?page=6 To understand discriminator, first you must understand the inheritance strategies: SINGLE_TABLE, JOINED, TABLE_PER_CLASS. Discriminator is commonly used in SINGLE_TABLE inheritance because you need a column to identify the type of the record. Example: You have a class Student and 2 sub-classes: GoodStudent … Read more

How do I encode enum using NSCoder in swift?

You need to convert the enum to and from the raw value. In Swift 1.2 (Xcode 6.3), this would look like this: class AppState : NSObject, NSCoding { var idx = 0 var stage = Stage.DisplayAll override init() {} required init(coder aDecoder: NSCoder) { self.idx = aDecoder.decodeIntegerForKey( “idx” ) self.stage = Stage(rawValue: (aDecoder.decodeObjectForKey( “stage” ) … Read more

How to store a dictionary on a Django Model?

If it’s really dictionary like arbitrary data you’re looking for you can probably use a two-level setup with one model that’s a container and another model that’s key-value pairs. You’d create an instance of the container, create each of the key-value instances, and associate the set of key-value instances with the container instance. Something like: … Read more

Java: JSON -> Protobuf & back conversion

As mentioned in an answer to a similar question, since v3.1.0 this is a supported feature of ProtocolBuffers. For Java, include the extension module com.google.protobuf:protobuf-java-util and use JsonFormat like so: JsonFormat.parser().ignoringUnknownFields().merge(json, yourObjectBuilder); YourObject value = yourObjectBuilder.build();

JPA 2 CriteriaQuery, using a limit

Define limit and offset on the Query: return em.createQuery(query) .setFirstResult(offset) // offset .setMaxResults(limit) // limit .getResultList(); From the documentation: TypedQuery setFirstResult(int startPosition) Set the position of the first result to retrieve. Parameters: startPosition – position of the first result, numbered from 0 TypedQuery setMaxResults(int maxResult) Set the maximum number of results to retrieve.

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