11 Temmuz 2012 Çarşamba

JPA tips 2


A previous post about this topic: http://hilaltarakci.blogspot.com/2011/03/jpa-tips.html

Actually, long version of this post includes notes taken while i was reading Chapter 9- Working with Objects of book Java Persistence with Hibernate (http://www.manning.com/bauer2/). However, i could not post it because of the copyright rules..

 But at least, i can recommend to buy the book and read the whole chapter..

free data models

I am trying to model a complex questionnaire and during my googling for best practices i discovered this website: http://www.databaseanswers.org/data_models/
An excellent site full of free and well prepared data models on several topics..

10 Temmuz 2012 Salı

free manual search engine

Discovering beneficial manuals, especially when newbie to a topic, technology etc.,  is vital.
 http://the-manuals.com/ seems to retrieve good documentation..

9 Temmuz 2012 Pazartesi

LINQ error: Null value for non-nullable member.

When i tried to save an object with a complex type (with a null instance of the complex type), i got the following error:

{"Null value for non-nullable member. Member: 'Sentence'."}

In this link there is an explanation for this: http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/50d33271-c8e3-468f-82e1-7c3178cb4322/
According to the explanation, complex types are always considered as required in entity framework. My workaround is creating an instance of the complex type with new keyword in the constructor.

5 Temmuz 2012 Perşembe

error during migration (update-database, codefirst)

I got the following error when i run Update-Database command in Package Manager Console of Visual Studio:


PM> update-database
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   --- End of inner exception stack trace ---
   at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Management.Automation.ComMethod.InvokeMethod(PSMethod method, Object[] arguments)
Exception has been thrown by the target of an invocation.


The solution is specifying the startup project (http://stackoverflow.com/questions/9174116/entity-framework-4-3-migration-exception-when-update-database):


Update-Database –ProjectName "MyInnerProject" –Force -ConnectionString "Data Source=.;Initial Catalog=initialcatalogname;Persist Security Info=True;User ID=userid;Password=password" -ConnectionProviderName "System.Data.SqlClient" -verbose -StartupProjectName "MyStartupProject"