entity

JPA Entity Mapped as OneToOne as well as OneToMany

Consider the following JPA entity. My application instance class must always have a OneToOne reference to 4 special instances of Envelope but it also has a set of 0-infinite user defined envelopes. Is this even possible? Is it possible with both Unidirectional and/or Bidirectional references? @Entity(name = "Application_Instance"...

Entity Updating strategy

There is some discussion on my team about updating entity data and how best to approach it. This is a security framework and so here are some of the constraints and ideas. every table in DB has a PK that is a guid, this is required for our multi-node clustering solution. The idea is that we don't want to expose this on an entity to a ...

Comparing entities while unit testing with Hibernate

I am running JUnit tests using in memory HSQLDB. Let's say I have a method that inserts some values to the DB and I am checking if the method inserted the values correctly. Note that order of the insertion is not important. @Test public void should_insert_correctly() { MyEntity[] expectedEntities = new MyEntity[2]; // init expec...

Adding & Removing Associations - Entity Framework

I'm trying to get to grips with EF this week and I'm going ok so far but I've just hit my first major snag. I have a table of items and a table of categories. Each item can be 'tagged' with many categories so I created a link table. Two columns, one the primary ID of the item, the other the primary ID of the category. I added some data m...

Entity Framework - Association From Derived Entities

Hi, I'm using the TPH (Table per Hierarchy) technique to map a set of entities. DB Schema: UserGroupLabelSpreads table having a "UserId", "GroupId" and "LabelId" nullable fields with some additional common fields. DAL Objects: - UserGroupLabelSpread abstract class. - UserSpread with a discriminator having only non-null UserId. - GroupS...

problem with a Many to many relations in Entity framework

I have 3 entities -Direction -City -GeoPosition each Direction have a Geoposition, and each City have a collection of Geopositions (this represent a polygon) I have 5 tables -directions -cities -geopositions -directionsgeopositions -citiesgeopositions and EF entities is this each entity have function imports for insert, update, and...

N:M relation and deleting records

I have three tables: Context, Component and ComponentContext. The ComponentContext table links the Component and Context into an N:M relationship. I'm working on a C# project which imports a bunch of data into these tables. It uses an Entity model and as a result, I only see an Component entity and a Context entity within my code. Now,...

How can I to order an EntityQuery query in a seam app?

My project was originally generated by seam-gen and the action "List" bean, OfficeViewList looks pretty much like it did when first generated. The bean extends EntityQuery. Now I want to order the results. What is the best way to do this? Do I want to add some kind of "order by" class to my EJBQL? Or do I want to set the select order...

How do I unescape XML special characters in Perl?

I'm processing some XML files (specifically .vcproj files) in Perl and I want to unescape the special characters. The escaped characters I've encountered so far are: " 
 
 Obviously I can do this myself but it seems that there should be a standard (or CPAN) module to do this but a naive search brings up nothing relevan...

Entity Binding in Winforms - one to many

I'm struggling with the Entity Framework when creating a new record in a one to many relation. I've the following tables defined: Person PersonInternetAddresses InternetAddresses The Entity Framework has created the EntityObjects Person with a navigation property named PersonInternetAddresses and InternetAddresses with a navi...

Referential identity in persistence frameworks

With our current persistence framework properties on a child entity that point to it's parent always point to the same instance. For example, given the following entity classes public class Order { public int OrderId{get;set;} public EntityCollection<LineItem> Items{get;} } public class LineItem { public Order Order{ get;se...

How to sort related entities with eager loading in ADO.NET Entity Framework

Greetings, Considering the Northwind sample tables Customers, Orders, and OrderDetails I would like to eager load the related entities corresponding to the tables mentioned above and yet I need ot order the child entities on the database before fetching entities. Basic case: var someQueryable = from customer in northwindContext.Custo...

JPA, How to use the same class (entity) to map different tables?

I have two tables: Ta and Tb. They have exactly the same table structure but different table names. I try to create one entity class to map the table structures. Some of my common application modules will use this entity class to dynamically query and update either Ta or Tb based on parameters. Can it be done in JPA? How can I write ...

Where should I put a unique check in DDD?

I'm working on my first DDD project, and I think I understand the basic roles of entities, data access objects, and their relationship. I have a basic validation implementation that stores each validation rule with it's associated entity. This works fine for rules that apply to only the current entity, but falls apart when other data i...

Linq to Sql + custom data types

Hello, I have a custom asp.net control i created that allows you to bind an object to it, it functions kinda like a winform propertygrid. Heres my issue: the control looks at the public properties and types of the class, if it detects a type of color it renders a color picker, etc.. Works great for classes that i create - however not...

Entity Framework EntityKey / Foreign Key problem.

As the result of a form post, I'm trying to save a new Brand record. In my view, Gender is a dropdown, returning an Integer, which is populated from ViewData("gender") I've setup my link as follows: gID = CInt(Request.Form("Gender")) Brand.GenderReference.EntityKey = New EntityKey("DB_ENTITIES.Gender", "Id", gID) TryUpdateModel(Brand) ...

Entity framework primary keys in Views

I have to use a View with the EF but, when e import it, the primary key of the view is displayed incorrectly and for some reason I can't change it. ...

Should I use Entities when data access is actually required?

Should I use Entities that are created by the Entity Framework in my code when I don't actually have any data based requirements. The example I am dealing with this is as follows; Users logs in. I look for their user account using Linq to Entity. I store the whole entity object in session. On the next page I load, from session, the auth...

Empty constructors and setters on JPA Entites

Hi! I don't like the requirement on have at least one empty constructor and public setters on JPA entities. While I understand the issue on the EntityManager side, this invalidates class invariants. Does anyone have a solution for this (design pattern or idiom level) ? Thanks! Igor ...

How to handle entity creation/editing in a master-detail

I'm wondering what strategies people are using to handle the creation and editing of an entity in a master-detail setup. (Our app is an internet-enabled desktop app.) Here's how we currently handle this: a form is created in a popup for the entity that needs to be edited, which we give a copy of the object. When the user clicks the "Can...