Skip to main content

Questions tagged [entity]

In computer science an entity is an object which has an identity and can be uniquely determined, holds storable information or can be processed. As the term has a very abstract and general meaning prefer to use this tag only in conjunction with other more specific tags.

Filter by
Sorted by
Tagged with
903 votes
35 answers
1.1m views

How to fix the Hibernate "object references an unsaved transient instance - save the transient instance before flushing" error

I receive following error when I save the object using Hibernate object references an unsaved transient instance - save the transient instance before flushing
Tushar Ahirrao's user avatar
349 votes
24 answers
719k views

PersistentObjectException: detached entity passed to persist thrown by JPA and Hibernate

I have a JPA-persisted object model that contains a many-to-one relationship: an Account has many Transactions. A Transaction has one Account. Here's a snippet of the code: @Entity public class ...
Paul Sanwald's user avatar
  • 11.2k
244 votes
17 answers
334k views

How to update only one field using Entity Framework?

Here's the table Users UserId UserName Password EmailAddress and the code.. public void ChangePassword(int userId, string password){ //code to update the password.. }
h3n's user avatar
  • 5,228
179 votes
18 answers
361k views

How to set a default entity property value with Hibernate

How do I set a default value in Hibernate field?
Dejell's user avatar
  • 14.2k
158 votes
14 answers
183k views

How to delete an object by id with entity framework

It seems to me that I have to retrieve an object before I delete it with entity framework like below var customer = context.Customers.First(c => c.Id == 1); context.DeleteObject(customer); ...
Jeff's user avatar
  • 1,581
137 votes
4 answers
190k views

What is the difference between persist() and merge() in JPA and Hibernate?

What is the difference between persist() and merge() in Hibernate? persist() can create a UPDATE & INSERT query, eg: SessionFactory sef = cfg.buildSessionFactory(); Session session = sef....
Jimit Tank's user avatar
  • 1,519
135 votes
6 answers
116k views

What is difference between a Model and an Entity [closed]

I am seeking clarification on the definitions of the terms Entity, Model, DataModel, and ViewModel within the context of software development. Could someone provide a detailed explanation for each of ...
amiry jd's user avatar
  • 27.4k
116 votes
11 answers
114k views

Improving bulk insert performance in Entity framework [duplicate]

I want to insert 20000 records in a table by entity framework and it takes about 2 min. Is there any way other than using SP to improve its performance. This is my code: foreach (Employees item in ...
Vahid Ghadiri's user avatar
110 votes
1 answer
63k views

cascade={"remove"} VS orphanRemoval=true VS ondelete="CASCADE

I tried to gather some information about the following way to delete automatically child entity when a parent entity is deleted. Seems that the most common way is to use one those three annotation: ...
Alexis_D's user avatar
  • 1,948
98 votes
4 answers
133k views

Difference between Entity and DTO

What is the difference between a DTO and an Entity? In details these are my questions: What fields should the DTOs have? For example my entity classes are: @Entity public class MyFirstEntity ...
Display Name's user avatar
  • 1,181
88 votes
15 answers
96k views

EF 4.1 exception "The provider did not return a ProviderManifestToken string"

I am trying to replicate an example found on MSDN. I am using ASP.NET and EF 4.1 (CTP?). I've used NuGet to install the EntityFramework package. I am getting this error: The provider did not return a ...
bugnuker's user avatar
  • 3,948
86 votes
4 answers
74k views

Differentiating between domain, model, and entity with respect to MVC

Can someone explain these 3 concepts and the differences between them with respect to an MVC framework along with an example. To me these appear almost equivalent, and it seems they are used ...
Martin Konecny's user avatar
86 votes
5 answers
53k views

Entity Framework - Is there a way to automatically eager-load child entities without Include()?

Is there a way to decorate your POCO classes to automatically eager-load child entities without having to use Include() every time you load them? Say I have a Class Car, with Complex-typed ...
Nathan Geffers's user avatar
81 votes
10 answers
111k views

What's the HTML character entity for the # sign?

What's the HTML character entity for the # sign? I've looked around for "pound" (which keeps returning the currency), and "hash" and "number", but what I try doesn't ...
chimerical's user avatar
  • 5,993
74 votes
7 answers
82k views

How can I disable migration in Entity Framework 6.0 [duplicate]

I'm trying to ignore the "Automatic" migration using Entity Framework 6.0 rc1. My problem is that I don't want this feature right now and every time that my application runs I can see all entity logs ...
Michel Borges's user avatar
72 votes
6 answers
47k views

Should I write equals() and hashCode() methods in JPA entities?

I want to check if entity is in a Collection member (@OneToMany or @ManyToMany) of another entity: if (entity2.getEntities1().contains(entity1)) { }
j2j's user avatar
  • 821
70 votes
5 answers
125k views

SQL JPA - Multiple columns as primary key

If i want severeal Column to make up an ID. SQL example : CONSTRAINT [PK_NAME] PRIMARY KEY ([Column1],[Column2],[Column3]) How can i do that with a Jpa Entity class ? through columndefinition ? ...
Anders Pedersen's user avatar
70 votes
5 answers
34k views

DDD and MVC: Difference between 'Model' and 'Entity'

I'm seriously confused about the concept of the 'Model' in MVC. Most frameworks that exist today put the Model between the Controller and the database, and the Model almost acts like a database ...
Nathan Loding's user avatar
69 votes
5 answers
43k views

Symfony2 collection of Entities - how to add/remove association with existing entities?

1. Quick overview 1.1 Goal What I'm trying to achieve is a create/edit user tool. Editable fields are: username (type: text) plainPassword (type: password) email (type: email) groups (type: ...
ioleo's user avatar
  • 4,787
66 votes
9 answers
80k views

How to clone a JPA entity

I have a JPA entity already persisted in the database. I would like to have a copy of it (with a different id), with some fields modified. What is the easiest way to do this? Like: setting it's @Id ...
krisy's user avatar
  • 1,528
62 votes
7 answers
90k views

What's the difference between entity and class?

Is entity an instance of class?
Steven's user avatar
  • 25k
62 votes
3 answers
49k views

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 ...
user avatar
62 votes
12 answers
69k views

How can I get my database to seed using Entity Framework CodeFirst?

The database is created successfully (as are the tables) but is not seeded. I have spent several hours and read tons of articles but have not been able to get it. Any suggestions? On a side note, is ...
Alec's user avatar
  • 1,696
58 votes
6 answers
87k views

Entity Framework and Multi threading

We are having some trouble designing our multi-threaded Entity Framework driven application and would like some guidance. We are creating entities on different threads, the entities are added to ...
Martin Richards's user avatar
54 votes
8 answers
90k views

Disable caching in JPA (eclipselink)

I want to use JPA (eclipselink) to get data from my database. The database is changed by a number of other sources and I therefore want to go back to the database for every find I execute. I have read ...
James's user avatar
  • 3,625
54 votes
8 answers
94k views

Java entity - why do I need an empty constructor?

This might sound stupid to you, but why do I need to define an empty constructor in my @Entitys? Every tutorial I saw said : every entity needs an empty constructor. But Java always give you a default ...
sliders_alpha's user avatar
49 votes
5 answers
90k views

Configure JPA to let PostgreSQL generate the primary key value

So our project use PostgreSQL database and we use JPA for operating the database. We have created the entities from the database with automatic creator in Netbeans 7.1.2. After small changes our ...
Atais's user avatar
  • 11.2k
48 votes
5 answers
55k views

nuget retrieving package metadata

An error occurred while retrieving package metadata for 'bootstrap.3.3.5' from source 'nuget.org'. ========== Finished ========== Where the defect wonder Is site nuget.org may crash or whether ...
Sultan's user avatar
  • 700
48 votes
7 answers
100k views

XML Entity for "/"?

So I'm writing some XML generating code, and found that the following attribute value was screwing up the XML formatting: "Jim/Bob" So I looked into the XML Entities used as escape sequences and ...
Alpants's user avatar
  • 916
47 votes
9 answers
93k views

org.postgresql.util.PSQLException: ERROR: column user0_.id does not exist - Hibernate

I have a model class that is mapped to a postgres database using hibernate. My model class is: @Entity @Table(name="USER") public class User { @Id @GeneratedValue @Column(name="id") ...
kovac's user avatar
  • 5,331
46 votes
23 answers
259k views

org.hibernate.MappingException: Unknown entity: annotations.Users

Consider the hierarchy : And the following classes and xml : HibernateUtil.java package annotations; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org....
JAN's user avatar
  • 21.7k
46 votes
3 answers
36k views

JPA entity id - primitive or object type (long or Long)

Should the ID of your Entity be long (primitive type) or Long (object type)? The ID is the primary key of my table and is never 'null' in the database. My co-workers suggest to use an Object Type ...
Dimitri Dewaele's user avatar
45 votes
5 answers
118k views

symfony2 Catchable Fatal Error: Object of class could not be converted to string

I have this Entity defined: <?php namespace Apw\BlackbullBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; /** * Categories * * @ORM\Table() * @...
Falar's user avatar
  • 519
45 votes
4 answers
71k views

What is the exact meaning of the JPA @Entity annotation?

I am studying JPA in Spring application and I have some doubts related to the @Entity annotation. So I have a model class like this: @Entity @Table(name= “T_CUSTOMER”) public class Customer { @...
AndreaNobili's user avatar
  • 42.3k
43 votes
7 answers
64k views

JPA thinks I'm deleting a detached object

I've got a DAO that I used to load and save my domain objects using JPA. I finally managed to get the transaction stuff working, now I've got another issue. In my test case, I call my DAO to load a ...
Steve's user avatar
  • 2,700
40 votes
1 answer
41k views

How to access the entity inside the buildForm method of a form

I'm trying to get the entity inside the own form. I lazy remember a getData() method, but it doesn't exist inside the form, and I can't remember how to use it. Is there any way to get the entity ...
Angel's user avatar
  • 1,970
39 votes
9 answers
103k views

Generate JPA 2 Entities from existing Database

How can I generate JPA2 compliant @Entity from existing Databases?. I found this: Question Still its not clear if JBoss will generate compliant JPA2 and also I would like to know if there is a ...
will824's user avatar
  • 2,234
39 votes
6 answers
106k views

XML parser error: entity not defined

I have searched stackoverflow on this problem and did find a few topics, but I feel like there isn't really a solid answer for me on this. I have a form that users submit and the field's value is ...
NightHawk's user avatar
  • 3,621
39 votes
6 answers
43k views

How to retrieve mapping table name for an entity in JPA at runtime?

Is it possible to determine the native table name of an entity? If a Table annotation is present it's easy: entityClass.getAnnotation(Table.class).name() But what about if no Table annotation is ...
marabol's user avatar
  • 1,257
38 votes
4 answers
40k views

What are the HTML entities for up and down triangles?

I've found the outlined versions, but I want the solid up and down triangles. Does anyone know these entities?
alex's user avatar
  • 487k
38 votes
3 answers
43k views

Symfony 2.0 getting service inside entity

Im seraching over and cannot find answer. I have database role model in my application. User can have a role but this role must be stored into database. But then user needs to have default role ...
Kaminari's user avatar
  • 1,487
38 votes
1 answer
40k views

Symfony2: get the id of the persisted object

I have two entity: User and Person. In the entity User I need the id of the associated person: user_id. When I am creating a new user, I have to create first the person and then the user. In the ...
Milos Cuculovic's user avatar
38 votes
8 answers
34k views

JPA 2.0: Adding entity classes to PersistenceUnit *from different jar* automatically

I have a maven-built CDI-based Java SE app, which has a core module, and other modules. Core has the persistence.xml and some entities. Modules have additional entities. How can I add the entities to ...
Ondra Žižka's user avatar
36 votes
2 answers
29k views

check constraint entity framework

IN EF can I add a check constraint so if my CustomerNotes entity has a boolean "FollowUpRequired" property I force user to enter a valid future date in the "FollowUpDate" property?
CheGuevarasBeret's user avatar
36 votes
5 answers
11k views

The type 'Company.Model.User' and the type 'Company.Core.Model.User' both have the same simple name of 'User' and so cannot be used in the same model

I have a base entity class MyCompany.Core.Model.User which is to be used for common properties of a User entity: public class User { public string Username { get; set; } public string ...
Brett Postin's user avatar
  • 11.3k
35 votes
3 answers
32k views

Detached Entity and Managed Entity

What a "detached entity" means? How is it possible to convert a managed entity to a detached entity during a transaction?
Shemil's user avatar
  • 387
34 votes
4 answers
61k views

Efficient way of updating list of entities

I am working on a project which allows the user to edit a list of entities. I map these entities to view models and display them with editor fields. When the user presses the submit button, I go ...
Stefan Bossbaly's user avatar
32 votes
2 answers
24k views

Entity Framework 4.1 InverseProperty Attribute and ForeignKey

I will create two references between Employee and Team entities with foreign keys. So I defined two entities as follow public class Employee { public int EmployeeId { get; set; } public ...
Ray's user avatar
  • 4,088
32 votes
9 answers
33k views

Entities equals(), hashCode() and toString(). How to correctly implement them?

I'm implementing equals(), hashCode() and toString() of my entities using all the available fields in the bean. I'm getting some Lazy init Exception on the frontend when I try to compare the equality ...
spike07's user avatar
  • 829
31 votes
13 answers
33k views

Could not build ClassFile - ArchiveException

We develop an application with spring, jpa, tomcat, maven, etc. Locally on my developer machine everything works fine but when we deploy the application on a linux server I get the following ...
myborobudur's user avatar
  • 4,425

1
2 3 4 5
130