Class Mapping Error: ‘T’ must be a non-abstract type with a public parameterless constructor

The problem is that you’re trying to use the T from SqlReaderBase as the type argument for MapperBase – but you don’t have any constraints on that T. Try changing your SqlReaderBase declaration to this: public abstract class SqlReaderBase<T> : ConnectionProvider where T : new() Here’s a shorter example which demonstrates the same issue: class … Read more

Navigation Property without Declaring Foreign Key

I believe, it is not possible to define the relationship only with data attributes. The problem is that EF’s mapping conventions assume that Creator and Modifier are the two ends of one and the same relationship but cannot determine what the principal and what the dependent of this association is. As far as I can … Read more

Entity Framework 4.1 InverseProperty Attribute and ForeignKey

It is theoretically correct but SQL server (not Entity framework) doesn’t like it because your model allows single employee to be a member of both First and Second team. If the Team is deleted this will cause multiple delete paths to the same Employee entity. This cannot be used together with cascade deletes which are … Read more

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.

Using AutoMapper to unflatten a DTO

This also seems to work for me: Mapper.CreateMap<PersonDto, Address>(); Mapper.CreateMap<PersonDto, Person>() .ForMember(dest => dest.Address, opt => opt.MapFrom( src => src ))); Basically, create a mapping from the dto to both objects, and then use it as the source for the child object.

How to introduce multi-column constraint with JPA annotations?

You can declare unique constraints using the @Table(uniqueConstraints = …) annotation in your entity class, i.e. @Entity @Table(uniqueConstraints={ @UniqueConstraint(columnNames = {“productId”, “serial”}) }) public class InventoryItem { … } Note that this does not magically create the unique constraint in the database, you still need a DDL for it to be created. But seems like … Read more

tech