JPA Map mapping

Although answer given by Subhendu Mahanta is correct. But @CollectionOfElements is deprecated. You can use @ElementCollection instead: @ElementCollection @JoinTable(name=”ATTRIBUTE_VALUE_RANGE”, joinColumns=@JoinColumn(name=”ID”)) @MapKeyColumn (name=”RANGE_ID”) @Column(name=”VALUE”) private Map<String, String> attributeValueRange = new HashMap<String, String>(); There is no need to create a separate Entity class for the Map field. It will be done automatically.

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

How to load a separate Application Settings file dynamically and merge with current settings?

Well, this works: using System; using System.Configuration; using System.IO; using System.Linq; using System.Xml.Linq; using System.Xml.XPath; public static class SettingsIO { internal static void Import(string settingsFilePath) { if (!File.Exists(settingsFilePath)) { throw new FileNotFoundException(); } var appSettings = Properties.Settings.Default; try { var config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.PerUserRoamingAndLocal); string appSettingsXmlName = Properties.Settings.Default.Context[“GroupName”].ToString(); // returns “MyApplication.Properties.Settings”; // Open settings file … Read more

How to save data in iOS

Let’s say you want to save score and level, which are both properties of an object called dataHolder. DataHolder can be created as a singleton, so you don’t have to worry too much about from where you access it (its sharedInstance actually): It’s code would look a bit like this: DataHolder.h #import <Foundation/Foundation.h> @interface DataHolder … 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