entity-relationship

Is there a way to get all managed entities from an EntityManager

≯℡__Kan透↙ 提交于 2019-12-04 23:12:50
I'm setting up a basic test data util and want to keep track of all the data that the EntityManager handles. Rather than just having a bunch of lists for each entity is there a way to grab everything being managed by the EntityManager in one fell swoop? So instead of this: EntityManager em; List<Entity1> a; List<Entity2> b; ... List<Entityn> n; cleanup() { for(Entity1 e : a) em.remove(e); for(Entity2 f : b) em.remove(f); ... for(Entityn z : n) em.remove(z); } I want something like this; EntityManager em; cleanup() { List<Object> allEntities = em.getAllManagedEntities(); //<-this doesnt exist

How to know relations between tables

大城市里の小女人 提交于 2019-12-04 22:38:50
I have a database in MySQL created by someone. I don't have any documentation of the database. How can I know the relationship between the tables? Is there any query or a procedure to generate a report so that it's easy to find the relations? I can look into Schema information and manually figure it out, but it would be great if I could generate a relationship report. The better way as programmatically speaking is gathering data from INFORMATION_SCHEMA.KEY_COLUMN_USAGE table as follows: SELECT `TABLE_SCHEMA`, -- Foreign key schema `TABLE_NAME`, -- Foreign key table `COLUMN_NAME`, -- Foreign

what's the best way to search a social network by prioritizing a users relationships first?

不问归期 提交于 2019-12-04 18:02:46
I have a social network set up and via an api I want to search the entries. The database of the social network is mysql. I want the search to return results in the following format: Results that match the query AND are friends of the user performing the search should be prioritized over results that simply match the query. So can this be done in one query or will I have to do two separate queries and merge the results and remove duplicates? I could possibly build up a data structure using Lucene and search that index efficiently, but am wondering if the penalty of updating a document everytime

Symfony Doctrine entity friend hasFriend followers

偶尔善良 提交于 2019-12-04 17:25:42
I need to set follower, following (myFriends) hasFriend logic to my project. column "odobera" means "following" to example nick(id user) odobera (following to this user). User (25) is following user(37). Requests table: User entity: /** * @ORM\OneToMany(targetEntity="TB\RequestsBundle\Entity\Requests", mappedBy="odobera") */ protected $followers; /** * @ORM\OneToMany(targetEntity="TB\RequestsBundle\Entity\Requests", mappedBy="nick") */ protected $myFriends; public function __construct() { parent::__construct(); $this->followers = new \Doctrine\Common\Collections\ArrayCollection(); $this-

ASP.NET MVC : Generating multi level menu using recursive helpers

杀马特。学长 韩版系。学妹 提交于 2019-12-04 14:27:19
问题 I am using this code for generating menu, this menu populates items from database (Category Table) using this technique Partial View : @using SarbarzDarb.Helper @model IEnumerable<SarbarzDarb.Models.Entities.Category> @ShowTree(Model) @helper ShowTree(IEnumerable<SarbarzDarb.Models.Entities.Category> categories) { foreach (var item in categories) { <li class="@(item.ParentId == null && item.Children.Any() ? "dropdown-submenu" : "")"> @Html.ActionLink(item.Name, actionName: "Category",

Is there a nosql store that also allows for relationships between stored entities?

故事扮演 提交于 2019-12-04 13:14:36
I am looking for nosql key value stores that also provide for storing/maintaining relationships between stored entities. I know Google App Engine's datastore allows for owned and unowned relationships between entities. Does any of the popular nosql store's provide something similar? Even though most of them are schema less, are there methods to appropriate relationships onto a key value store? It belongs to the core features of graph databases to provide support for relationships between entities. Typically, you model your entities as nodes and the relationships as relationships/edges in the

ERD - How to model a relation between two entites with a third entity as “attribute”

萝らか妹 提交于 2019-12-04 12:47:24
I'm modeling an entity relationship diagram and got stuck. I'm not sure if my considerations are wrong or an ERD can't modell what I want: I have three entities: Employee, Project and Role. There is a relation between Employee and Project: an employee is working on a project. But this employee isn't just working on this project, he/she has a field of operation that is given as a role. But isn't a relation just described by attributes? How can I make something like "An employee works on this project as ..."? Of course I got use a roleId as an attribute as I would design it as a database, but

EF Code first related entities context fail

泪湿孤枕 提交于 2019-12-04 11:42:20
Dunno how to name this properly. I have two entities in m:n relationship: Member and Role. public class Role { public int Id { get; set; } public string Title { get; set; } public ICollection<Member> MembersInRole { get; set; } } public class Member { public int Id { get; set; } public string Name { get; set; } public string Password { get; set; } public string Email { get; set; } public ICollection<Role> Roles { get; set; } } I have made some seed data: http://i56.tinypic.com/2vjvj1w.png And wrote test: The problem is, that my Member entity has no roles assigned, even when I created them in

Maintaining multiple one-to-many

巧了我就是萌 提交于 2019-12-04 06:42:46
问题 Following on from NHibernate one-to-one vs 2 many-to-one Is there an easy way to maintain multiple one-to-many relationships which are being used as a pseudo one-to-one. E.g. If I have 2 entities, User and Contact, which are related by a FK on each (User.ContactId and Contact.UserID). What is the best way to maintain that each reference points at the other. It would be wrong for the system to update User with a different contact, but the Contact still references User... 回答1: Most likely you

Doctrine: Object of class User could not be converted to string

无人久伴 提交于 2019-12-04 06:08:41
I keep getting this error with Doctrine: PHP Catchable fatal error: Object of class User could not be converted to string in vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 1337 In my system users can have many permissions in a One to Many relationship. I have set up a User and Permission entity. They look like this (I removed some annotations, getters and setters to reduce clutter): class User { /** * @ORM\Column(name="user_id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ protected $id; public function getId() { return $this->id; } /** *