Menu
  • HOME
  • TAGS

Symfony comparing two entities and getting names of different fields

symfony2,entity

$foo = new Foo(); $bar = new Bar(); $array_diff = array_keys( array_diff_key( get_object_vars($foo), get_object_vars($bar) )); $array_diff will be an array that contains every property that is into an entity but not into the other - or vice-versa I'm from my smartphone so I didn't tested it...

In Entity Framework, how do I add a generic entity to its corresponding DbSet without a switch statement that enumerates all the possible DbSets?

c#,database,entity-framework,entity

You might consider a generic class like so: public class GenericRepository<T> : where T : class { internal YourConext context; internal DbSet<T> dbSet; public GenericRepository(YourContext context) { this.context = context; this.dbSet = context.Set<T>(); } public virtual void Insert(T entity) { dbSet.Add(entity); context.SaveChanges(); } } ...

Hibernate's Criteria With Example And Query Return different results

java,spring,hibernate,entity

What is happening here is as a result of the fact that you have mapped ItemParentCategory to ItemSubcategory as FetchType.EAGER. Now, this does not affect your HQL query as HQL queries will not respect the EAGER mapping and to eager fetch the sub categories in HQL you would have to...

How do I properly initialize / define an object of the Text Class in Google App Engine?

java,google-app-engine,constructor,entity

In the documentation you linked, the constructor needs a string. So you would have to try it like this: Text text = new Text("stuff"); ...

angularjs - springboot - spring data/rest

angularjs,save,entity

I found a solution. I created a controller in Java taking in input all attributes from the app.js. @RequestMapping(value="/create/{name}/{status}",method = RequestMethod.POST,headers="Accept=application/json") public Customer create( @PathVariable String name, @PathVariable String status){ Customer customer = new Customer(); customer.setName(name); RefStatus refStatus = refStatusRepository.findByCode(status); customer.setStatus(refStatus); return this.customerRepository.save(customer); } I don't know if is it...

Flattening nested entities with ids in Clojure

dictionary,clojure,functional-programming,entity,flatten

tree-seq and for to the rescue! (for [m (tree-seq map? vals data) ;; traverse nested maps :when (map? m) ;; we only care about maps [k v] m ;; traverse key-value-pairs :when (not= k :id)] ;; ignore the ':id' key [(:id m) k (if (map? v) (:id v) v)]) ;;...

Fill my form with the data that I pick up from a table - Symfony2

forms,symfony2,entity,dql

I think what you want to do can be done by following these steps : Start by collecting your User data in a variable we will call $user Then, give this $userto be hydrated by your form, like this : $form = $this->createForm(new UserType(), $user); Treat your form like you...

How to do to have a generic Entity for SQL audit tables with JPA or Hibernate?

generics,jpa,entity,reverse-engineering,generic-programming

I found that: AuditReader.getAuditReader().createQuery().forRevisionsOfEntity(EntityClass.class, false, true).getResultList(); to get All data of an Entity X in the Audit Table...

overload resolution failed

vb.net,linq,frameworks,entity

Suggested fix (with '1's changed to 'l's): Return context.Logins _ .Include("Account.Children") _ .Include("aspnet_Membership") _ .Include("AccountType") _ .AsQueryable() _ .Where(Function(l) Not l.aspnet_Membership.Deleted AndAlso(l.FirstName.Contains(searchTerm) OrElse l.LastName.Contains(searchTerm) OrElse l.aspnet_Membership.Email.Contains(searchTerm) OrElse (l.FirstName & " " & l.LastName).Contains(searchTerm) OrElse l.Account.Children.Any(Function(c) (c.FirstName & " " & c.LastName).Contains(searchTerm)))) _...

How to catch exceptions in entity?

php,symfony2,entity

Your entity shouldn't really contain business logic for your application, its purpose is to map objects to the database records. The way to approach this depends on the application, for example if you have a File Controller and a removeAction within then the best place to remove the file would...

What harm do “invalid entities” do?

symfony2,database-design,doctrine2,entity

It might be the case that Doctrine2 knows how to detect those incorrect relationships and more importantly knows how to mitigate the issue. You should, however, fix the relationships as soon as possible in order to prevent future issues, in case they decide to change/remove "smart" logic ;) Other, more...

VB.NET Entity Framework Does context load all records when it's created?

c#,.net,vb.net,entity-framework,entity

Entity framework uses deferred loading, meaning the data is loaded only when specifically requested. The db context object you create only acts as an interface to the database. Any action you make on the context, like adding an object, is only applied to the database when calling .SaveChanges() on the...

Symfony2 insert multiple entities

symfony2,entity,entitymanager,persist

Since you are instantiating your object with the new Operator, there technically can be no duplicate. If you are concerned about duplicates in your array, which is filling the Objects Attribute, doctrine does not care about this. For Doctrine those are as many new entities as iterations in your foreach...

How to convert html entities into hex entities in php?

php,html,hex,entity

First of all, the "hex entities" are the entities with the character represented as Unicode codepoint. All Unicode characters could be represented as entities with the Unicode codepoint; in HTML, some can be represented with just a name, instead. The list of entities in HTML which have a predefined name...

Upload file function not hit symfony2

php,symfony2,entity

File upload not detected is Doctrine issue. Since file upload is not directly change the field where file name stored, Doctrine consider the entity as unchanged so it is ignored. This happens when only file upload is to be changed. You can mark the entity changes in controller, like that:...

Convert lambda expression to Json

asp.net-mvc,linq,lambda,kendo-ui,entity

In "Index_Read" method you are creating "IEnumerable of object" i.e. students which is not of "IEnumerable of Student" type. But in view you have binded your grid to "IEnumerable of Student". Since "Student" class doesn't contain "MyRegionName" property that's why you are facing issue. Try something like this: public ActionResult...

swift: core data with slideout navigation for a blog + multiple entities

ios,json,swift,core-data,entity

Yes, it is possible and it is advisable. Create a relationship between a Category entity and a MIBlog entity. When saving each MIBlog object to Core Data, you should check to see if a category by that name/id exists, and if it exists, use it, and if not, create that...

Passing a dbset as a parameter to a function

c#,ef-code-first,entity

You're looking for a generic method: private static void SetEntityPropertiesRequired<TEntity>(DbModelBuilder modelBuilder) { //set all decimal properties in Projection Entity to be Required var decimalproperties = typeof (TEntity).GetProperties() ... ...

org.hibernate.MappingException: Unknown entity: from xxx

hibernate,mapping,entity

I have change following line in model and this works for me. emp=session.createCriteria("from EmpTest").list(); to emp=session.createCriteria(EmpTest.class).list(); ...

Aggregate for one entity

entity,domain-driven-design,aggregate,ddd-repositories,aggregateroot

An aggregate root (AR) is an entity and it's very common to have entities which are the root of their own aggregate. Your User entity would simply be an aggregate root. You do not need an extra concrete class....

'System.Collections.Generic.List.Contains(int)' has some invalid arguments

linq,entity-framework,entity

You can't compare int? and int. Use c.PlantSupplyId.HasValue && result.Contains(c.PlantSupplyId.Value) instead...

What exactly returns EntityUtils.toString(response)?

android,apache,rest,entity

An HttpEntity represents the content of the body of an HTTP response. EntityUtils.toString(HttpEntity) interprets that content as a String and returns it to you. If your HTTP response is something like this HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: 80 <?xml version="1.0" encoding="utf-8"?> <root> <nested attr="whatever" /> </root> Then the...

How large of a String should generally be stored in one core data entity attribute?

ios,core-data,attributes,entity

Whether to use one attribute or multiple attributes depends only on whether the data is logically a single value or multiple values. That is, it depends entirely on the structure of the data, not its size. However, for excessively large values, it often makes more sense to save the data...

What is the best way to build a model/entity in Scala to map with Squeryl?

scala,model,playframework-2.0,entity,squeryl

In Squeryl 0.9.5, all entities needed to extend KeyedEntity[T] however with 0.9.6 you can provide the KeyedEntityDef implicitly. See this for an example. Option[T] is used when the field can contain null values. When the field is null, None is returned. As for val vs. var it is exactly as...

AngularJS & Entity Framework - Creating association without duplicating entity

angularjs,entity-framework,asp.net-web-api,entity

I fixed it by making sure to set the state of my entity. _uow.UOWContext.Entry(eq).State = System.Data.Entity.EntityState.Modified; The state of the entity that was getting posted was "Detached", so I set it to modified instead and it works perfectly....

Symfony entity field type with custom unselectable separators

forms,symfony2,select,entity

You could use optgroup tag to group cities by specified field. Just add 'group_by' => 'field_name' option to the city field.

EasyCriteria: We could not find the parameter: creationDate in the given class Assignment

jpa,inheritance,entity,criteria

Okay I updated EasyCriteria 3.0.0 to UaiCriteria 4.0.0 (name changed for legal reasons) and that fixed the problem. Remember to make sure that you don't have the old dependency remaining in Maven dependencies even after removing it from pom.xml and adding the new dependency there. I'm using Eclipse m2 plugin....

Persist entity nosql (hadoop/hbase/hive)

java,hadoop,entity,hbase,persist

I had a pretty hard time trying to understand your question, so my answer is going to be very generic. You should start by reading a few HBase books: http://hbase.apache.org/book.html http://www.amazon.es/HBase-Definitive-Guide-Lars-George/dp/1449396100 You've got good JAVA examples for almost anything you need on Lars' repo: https://github.com/larsgeorge/hbase-book In case you want to...

JPA, Hibernate can I do composite primary key which one element is foreign kay @OneToMany?

hibernate,jpa,foreign-keys,entity,composite-primary-key

Get rid of the providerId field and its corresponding getter and setter. Add an @Id annotation to getProvider(). Define the IdClass like this: public class ServicePointId { private Long provider; private Integer servicePointNumber; public Integer getProvider() { return provider; } public void setProvider(Integer provider) { this.provider = provider; } public...

Set an Entity Id as a function of other Entity

symfony2,orm,doctrine,entity,relationship

You shouldn't have a OneToOne on your User's primary key. It should be a separate $author variable: class User extends BaseUser { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\OneToOne(targetEntity="Author") * @JoinColumn(name="author_id", referencedColumnName="id") **/ private $author; } It's easier to manage if you keep it...

Symony2 Access form in entity prePersist?

php,symfony2,entity

My suggestion is to create a Doctrine subscriber and inject whatever service you want (xml example): service.xml <service id="my.doctrine.subscriber" class="%my.doctrine.subscriber.class%"> <argument type="service" id="form.factory" /> <argument type="service" id="request_stack" /> <tag name="doctrine.event_subscriber" connection="default" /> </service> MyDoctirneSubscriber class MyDoctirneSubscriber implements EventSubscriber { private $formFactory; private $requestStack; /** * @param ContainerInterface...

Entity Framework Search Function ASP.NET Webforms

asp.net,search,frameworks,entity,repeater

It looks like you're attempting to match the data field exactly instead of the partial name ans you specified. The following snippet shows how to get a partial field look-up using the Contains operator. Try this: var results = from p in db.Products where p.Name.Contains(searchWord) select p; ...

Symfony entity field : manyToMany with multiple = false - field not populated correctly

php,forms,symfony2,doctrine2,entity

If you want to set the multiple option to false when adding to a ManyToMany collection, you can use a "fake" property on the entity by creating a couple of new getters and setters, and updating your form-building code. (Interestingly, I saw this problem on my project only after upgrading...

Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property customer invoice

jpa,entity,spring-data

Probably because Orders has a property 'customers' and not 'Customers' (as specified by the 'mappedBy' attribute). You should tidy up your class names and fields as below: @Entity @Table(name="Customers") public class Customer implements Serializable { private static final long serialVersionUID = 1L; @Id @GenericGenerator(name = "generator", strategy = "increment") @GeneratedValue(generator...

Can I set a field value in an Entity by providing the field name?

symfony2,reflection,entity

You can use the Property Accessor component which will allow you to do just this. You simply provide your object, the field name and the value to set it to and the component will handle the rest (pubic properties, _set or setters). use Symfony\Component\PropertyAccess\PropertyAccess; // ... $value = $request->get('value'); $em...

Symfony2 Entity with criteria and params

symfony2,entity,criteria

Instead of calling the property translatedData.property on your entity you can simply call your method directly in twig: {{ mainEntity.getTranslatedData('your_language') }} It will allow you to pass a parameter....

Missing something in this method to get the Entity property

c#,asp.net-mvc,reflection,entity

var result = new List<string>(); var type = eContentField.GetType(); foreach (var prop in type.GetProperties()) { result.Add(prop.Name); } return result.ToArray(); } This is about twice faster than your method, if you are interested in speed. Ps: if you change the foreach into a for loop, it wil be a bit faster,...

Stop prePersist LifeCycleEvent being recursive in Doctrine2 Entiy

php,symfony2,recursion,doctrine2,entity

As the prePersist event is triggered before the entity is actually scheduled for insertion in the unit of work, you can just change the entity state here without having to manually call persist/flush. Simply do your stuff in your callback and don't bother about the entity manager....

How to use Linq to join entity tables with a cross-reference table

.net,linq,entity-framework,entity,entity-framework-6

I think what you looking for is a query like this: var keywordIds = new List<int> {1, 3, 5, 7, 9}; var items = (from s in db.Items from c in s.Keywords where keywordIds.Contains(c.KeywordId) select s).Distinct(); If you want to bring all the selected items to memory, then call the...

Is it possible to add two table's data in Seed method in Entity Framework(Code-first)?

entity-framework,entity-framework-4,entity-framework-5,entity,entity-framework-4.1

this is how i solved it.... public class ContextSeeder : DropCreateDatabaseIfModelChanges<Context> { protected override void Seed(Context context) { Examination e1 = new Examination() { Description = "Science", CutOffMark = 10, QuestionID = new List<Question>() { new Question() { QuestionDes = "What is a data bus?", Answer1 = "It carries a...

Symfony2 form type entity add extra option

php,forms,symfony2,entity

In your form type override the function finishView (http://api.symfony.com/2.6/Symfony/Component/Form/Extension/Core/Type/TimezoneType.html#method_finishView) : public function buildForm(FormbuilderInterface $builder, array $options){ $builder->add('measureunit', 'entity', array('label' => 'Measure Unit', 'class' => 'TeamERPBaseBundle:MeasureUnit', 'expanded' => false, 'empty_value' => '', 'multiple' => false, 'property' => 'abreviation' )) } public function finishView(FormView $view, FormInterface $form, array...

How to save data from Mapper to Entity using Left Joined data in PHP

php,mysql,entity,datamapper

I figured it out! Like I said in post above, I created a method inside Mapper class which runs through fetched rows from database and looks if it contains category_ string. If it does, then saves it in in special $category array. First I wanted to put this method inside...

Two records in database on 1 form

php,symfony2,doctrine2,entity,locale

If you want to retrieve some specific content based on the locale, you need to create an array where you set your fields ordered by locale and create a query that uses this array. You could do it this way : class PageLocaleManager { public function getParametersLocale() { // retrieve...

Symfony2 entity foreign keys

symfony2,doctrine2,foreign-keys,entity

Depending on how you get the user maybe it is a lazy load that you are using which will get the country only if you call the getter explicitly, to always get a country with the user try : /** * * @ORM\ManyToOne(targetEntity="Dashboard\MainBundle\Entity\Country", cascade={"persist"}, fetch="EAGER") * @ORM\JoinColumn(name="country_id", referencedColumnName="id", nullable=true) *...

Related entities don't save to a database Symfony2

symfony2,orm,doctrine2,entity,entity-relationship

Try setting 'by_reference' to false in your form : ->add('tags', 'entity', array( 'label' => 'Tags', 'class' => 'GeekhubMainBundle:Tag', 'property' => 'tagName', 'empty_value' => 'Choose a tag', 'multiple' => true, 'expanded' => false, 'by_reference' => false, // Makes sure that tags // are actually added to your post 'query_builder' => function...

Calling an entity method from controller

angularjs,symfony2,controller,entity

You should use -> instead of . to call method on an object: $follower_store->addFollowedStore($aStore); ...

Why JPA entities are treated like this outside a session?

jpa,entity

It can't do anything else. The only alternative would be to return an empty collection of employees, which would be much much worse: you would incorrectly assume that the enterprise has 0 employee, which is a valid, but completely incorrect result. To realize how much worse it would be to...

How do I write a test class for a Doctrine entity class?

symfony2,model,doctrine2,tdd,entity

This is a simple sample of unit test for an entity: class MessageTest extends \PHPUnit_Framework_TestCase { /** * @var Message */ protected $object; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() {...

Doctrine2 entity creation error : “Could not find driver”

php,symfony2,doctrine2,entity

It means you are missing pdo driver installed in your system. Depending on what db engine you configured in your parameters.yml it could be pdo_pgsql for instance. Check what php -i | grep pdo command says - you should see your extension installed. If not, you simply need to install...

Java EE - Entity getters doing minimal logic

java-ee,jpa,entity

What about: public class EntityA { private List<EntityB> listOfB = new ArrayList<EntityB>(); JPA Tools now generates Entities from tables in this manner and this works fine with JPA. This is a very nice solution, if you just want to make sure, that the List is initialized (and thus not null)....

Multiple behaviours for single entity

testing,process,entity,vhdl

This seems like an example where using multiple architectures of the same entity would help. You have a file along the lines of: entity TestBench end TestBench; architecture SimpleTest of TestBench is -- You might have a component declaration for the UUT here begin -- Test bench code here end...

Manipulate form data before persisting entity - Symfony 2.6

php,forms,symfony2,entity,symfony2-forms

if($form->isValid()) { $em = $controller->getDoctrine()->getManager(); $days = $request->get("form")["days"] //* calc end date here $endDate as \DateTime */ $listing->setEndDate($endDate); $em->persist($listing); $em->persist($product); $em->flush(); return true; } ...

Symfony2 Catchable Fatal Error: Argument 1 passed to entity Catchable Fatal Error: Argument 1 passed to entity

php,forms,symfony2,entity,symfony-2.6

Set data_class option for your InYourMindFriendType Checkout http://symfony.com/doc/current/reference/forms/types/form.html#data-class...

There is no ViewData item of type 'IEnumerable' that has the key 'GradingId'

c#,asp.net,asp.net-mvc,linq,entity

In Create get action you are not setting ViewBag.GradingId with the SelectList which is causing error in View: public ActionResult Create() { ViewBag.GradingId = new SelectList(db.Gradings, "GradingId", "CodeName"); return View(); } ...

Multiple entity in one form Symfony

php,symfony2,entity,twig

You may have to do something like this: Let's have this form type: class TicketType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder - > add('field1', 'text'); $builder - > add('field2', 'text'); $builder - > add('field3', 'text'); } public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver - > setDefaults(array(...

How to properly update a managed entity using data from a non-managed entity?

php,symfony2,doctrine2,entity

Controlling what Doctrine persists Update existing entities only if required. This can be achieved fairly simple with Doctrine: What you're looking for is the Change Tracking Policy Deferred Explicit. Doctrine will by default use the Change Tracking Policy Deferred Implicit. This means that when you call $em->flush(), Doctrine will go...

Can not define operator on list

c#,list,entity,operator-keyword

As Jon Skeet commented, this isn't possible. The idiomatic way to combine two sequences is to use Enumerable.Concat. This would let you combine the questions contained in two lists into a third list like so: var all = first.Concat(second).ToList(); ...

What does an entity's constructor look like for DDD in php?

php,constructor,entity,domain-driven-design,ddd-repositories

Passing array of values on the constructor is not a good idea. If the required data is not present in the array. your domain entity will be in invalid state. Just put the required fields individually on the constructor, that way it is more readable and the required fields are...

Select related entities in entity getter method in Symfony2

php,symfony2,doctrine,repository,entity

If you have the association set then you can use a get with a filter. public function getUpVotes() { return $this->ratings->filter( function (RatingInterface $rating) { return 1 === $rating->getUp(); } ); } ...

What is the cause of this EF6 behaviour Find() does not return a proxy but Single() does return a proxy

c#,entity-framework,entity,poco,proxy-classes

This could happen if your context is already tracking a non-proxy BankAccount with that key by the moment you query it. The strange thing is that, although First and Single always query the database, they should return the same entity as Find does. For example, if you have a unit...

Generate metadata from interface breeze+Typescript

typescript,entity,breeze

What is your server technology? Are you using Entity Framework on the server? If so, the metadata would come from the server. You extract it in your Web API controller through the EFContextProvider as illustrated here: http://www.getbreezenow.com/documentation/efcontextprovider Then on the client you would generate TS classes for each of your...

Is it good practice to have a getter for every property in a class representing a row, or should I investigate another approach?

php,oop,entity,data-entry

I think this is more of a design preference, but there are many advantages of using getters/setters. Encapsulation and hiding internals are typically good practice. Interoperability is another reason why using getters and setters is a good idea (ie. mocking becomes much easier). Whether you want to do this for...

A reference to the object element Symfony2

symfony2,doctrine,entity

For what you've currently shown, you got an array result. Currently your Message instance is being stored in $messages[0]. So you either have to iterate over your result (if you expect more than one record) or replace your findBy with findOneBy if you expect one record.

Symfony2 : Add method to an Entity

php,symfony2,entity,add

Looking at your code you replace your content with simple string. But in your template file you do not call that method at all, you directly access your getter. Also what does X characters means? If you want to truncate your title and return part of it, Symfony is providing...

JPA/Hibernate Query Slow with too many queries

hibernate,java-ee,jpa,entity

My guess is that the slowness is caused by the @NotFound annotations: Hibernate is probably forced to check if the department really exists. Using @NotFound is a hack to compensate for an inconsistent database where employees reference departments which don't exist. If your database is consistent (and that should be...

Object persistence doesn't work

java,glassfish,entity,persistence

The EJB container injects an entity manager in your bean, but you discard it and replace it by one you create yourself. All you need is @Stateless @LocalBean public class DAO { @PersistenceContext EntityManager em; public void createConnection(String nickName, String roomName) { Connexion c = new Connexion(); c.setNickName(nickName); c.setRoomName(roomName); c.setConnectionDate(new...

Designing JPA Entity for Database Table

mysql,database,hibernate,jpa,entity

An example JPA approach based on Rick's proposal: @Entity @Table(name = "States") public class State { @Id @Column(nullable = false, columnDefinition = "CHAR(2) CHARACTER SET ascii") private String code; @Column(nullable = false, length = 30) private String name; @OneToMany(mappedBy = "state") private Collection<District> districts; public State() { } // getters,...

Symfony2 - Best Practices to trigger 404 exception

php,symfony2,exception,model-view-controller,entity

You have to put your exceptions in methods that are called by your controller, and use those methods in every controller so you don't have to duplicate the code. You can : create Services which uses the Entity Repository and handle the Exceptions in it (http://symfony.com/doc/current/book/service_container.html) put Exceptions in your...

how can i get repository of many entities in one getRepository

symfony2,repository,entity

Your approach is not going to work, you should create a Repository and then Join your Tables, class CategorieRepository extends EntityRepository { public function getCategorieRelatedDataByIdAndIdPublication($idPublication) { $qb = $this->entityManager->createQueryBuilder(); $qb->select('c', 'e', 'p') ->from('PFESiivtBundle:Categorie', 'c') ->leftJoin('c.eveniment', 'e') ->leftJoin('c.project', 'p') ->where('c.id = :id') ->andWhere('c.idPublication = :id_publication') ->setParameter('id_publication',...

breeze.js not honoring the “noTracking” option when end point returns multiple result sets

api,entity,breeze

I can't reproduce the error you describe. I have a similar DocCode test that passes which references Breeze v1.5.3. Here is the pertinent NorthwindController method: [HttpGet] public object Lookups() { var regions = _repository.Regions; var territories = _repository.Territories; var categories = _repository.Categories; var lookups = new { regions, territories, categories...

Update a row(entity) in a table only if a change detected(automatically)

sql-update,entity,detect,cakephp-3.0,changes

Each entity has a field 'dirty' which shows if the entity has been updated. You could use something like : if($article->dirty()) { // send a flash message } Check the book here : http://book.cakephp.org/3.0/en/orm/entities.html#checking-if-an-entity-has-been-modified...

VHDL: Convert String to Std_Logic_Vector

string,entity,vhdl,sha

You can convert a string to bits with a function like this (untested): function to_std_logic_vector(a : string) return std_logic_vector is variable ret : std_logic_vector(a'length*8-1 downto 0); begin for i in a'range loop ret(i*8+7 downto i*8) := std_logic_vector(to_unsigned(character'pos(a(i)), 8)); end loop; return ret; end function to_std_logic_vector; I don't think type string...

How @BatchSize works in Hibernate deep explanation?

java,hibernate,jpa,entity

first of all. your @BatchSize annotation must be placed on the Manufacturer-Entity. This annotation can only be placed on Collection-fields. assuming that you corrected that ... if you take this jpql query SELECT p FROM product as p where p.manufacturer.name like :name hibernate will execute 1 select for the products...

Not equal condition not works Symfony2

php,symfony2,doctrine2,entity

If t.profile is an entity, you should compare like this: ->where('IDENTITY(t.profile) != :profile'); ...

Create A View, Select a Column As Primary Key

sql,entity,primary-key,sql-view

You cannot create primary keys on the view itself. To get around the no primary key issue, you can create a unique column that the entity framework will pick up and use. ISNULL(CAST((row_number() OVER (ORDER BY <columnName>)) AS int), 0) AS ID So: SELECT ISNULL(CAST((row_number() OVER (ORDER BY uniqueid)) AS...

Converting JPA Entities to a Map

java,mysql,jpa,entity

You can do that but no with JPA, after you get the list of your Work Entries, you can use Java reflection or more easier, use BeanUtils or JACKSON to convert any Java Bean ( in your case, WorkEntry class) into a Map. You can see this example of BeanUtils...

Using Entity Framework, how do I access the number of employees (one entity) corresponding to each office (another entity)?

c#,asp.net-mvc,linq,entity-framework,entity

Here is the easiest way on your database, doing the grouping and counting there: var result=db.Offices .Select(o=>new OfficeEmployeeCount{ OfficeName=o.BusinessName, EmployeeCount=o.Employees.Count()}); Then create your class OfficeEmployeeCount: public class OfficeEmployeeCount { public string OfficeName {get;set;} public int EmployeeCount {get;set;} } And access it in your view like so: @model IQueryable<OfficeEmployeeCount> <table> <thead><tr><th>Office...

AppBundle's Best Practice and how-to go further

php,symfony2,doctrine2,entity

If you follow the same strategy as your existing entities, you need to define the four entities in the following files: src/AppBundle/Entity/ForumCategory.php src/AppBundle/Entity/ForumPost.php src/AppBundle/Entity/ForumSection.php src/AppBundle/Entity/ForumTopic.php Then, the namespace of each entity will be namespace AppBundle\Entity; However, when you have several related entities, it's better to create a subdirectory inside the...

Count of childrens 1-* children *-* Linq Entity Framework

c#,linq,entity-framework,linq-to-entities,entity

Seems like something like this should work: foreach (var teacher in context.Teachers) { Console.WriteLine("The teacher '{0}' is teaching the following classes:", teacher.Name); foreach (var teacherClass in teacher.Classes) { Console.WriteLine(" - {0} ({1} students)", teacherClass.Name, teacherClass.Students.Count); } } ...

Entities passed to the choice field must be managed. Maybe persist them in the entity manager?

php,forms,symfony2,doctrine2,entity

Thanks to @Andariel, my relation was wrong (need a ManyToOne) For my second issue, I was able to register the user using the userManager of FOSUserBundle and it worked like a charm. Here is the code if it can help someone : if($form->isValid()){ //Getting the company from FORM Response $companyObject...

Symfony 2.6 : How to get the current provider used to log in?

php,symfony2,entity,provider

You can just check if your $this->getUser() is instanceof your desired entity: if ($this->getUser() instanceof SpeedDev\MyprojectsBundle\Entity\Employee) { // this is employee } ...

Symfony 2 - Class “Mingle\StandardBundle\Entity\Product” is not a valid entity or mapped superclass

php,symfony2,doctrine,entity,bundle

Annotations have to be placed inside /** */ comment block, otherwise they are not recognized.

Many to Many relationship JPA, EJB and new table in db

jpa,entity,eclipselink,ejb-3.1,javadb

You don't need to worry about that. @ManyToMany is implemented using a join table (AVOIR in your case), and the persistence provider takes care of wiring it all up in the database. Your responsibility is only to maintain both sides of the relationship, meaning if you add one Critere to...

How to get Container object from LifecycleEventArgs of postLoad in Entity?

php,symfony2,entity,containers,symfony-2.6

You can use setter-injection which result in a call to a predefined method (setContainer() in this case) with the container as an argument upon creation of the listener service: services: ibw.jobeet.entity.job.container_aware: class: Your\Bundle\Doctrine\Event\Listener\JobListener calls: - [setContainer, ["@service_container"]] tags: - { name: doctrine.event_listener, event: postLoad } Now the container is injected...

Drupal: Display number of times content is referenced in content by using views

drupal,reference,views,entity

You can do it using Nodereference count module: https://www.drupal.org/project/nodereference_count Another valid module is Entity Reference module, but it has only a dev version: https://www.drupal.org/project/entityreference_count Regards....

Symfony2 - Nested form with nested objects

php,forms,symfony2,object,entity

I'd go with a simpler approach. Create an Address entity and add a relation to both Customer and Company entities. An address is a very generic thing so there's no real reason why both Customer and Company can't just share that Address entity. Then you can just create a generic...

How would I add properties to an entity using a method instead of hard coding it (using Entity Framework)?

c#,asp.net-mvc,database,entity-framework,entity

I don't see how this is possible in the exact way that you describe it. If I needed to have this sort of "extensible" entity requirement, where users can dynamically add new properties, I would create a couple of generic tables + entities for that exact purpose. And it would...

DDD: Can an entity have attributes of primitive data types?

object,attributes,entity,domain-driven-design,value

While it is common attitude to compose an entity of another entities or value objects, it is not necessary. Please remember that you should think about an abstraction. Primitive types are ok when there is no business logic involved in using them. For example: public class User { private UserId...

Symfony2 - Entity Collection Choice Restriction

php,symfony2,doctrine,entity,twig

You can filter a collection in a form by restricting the query results. E.g. something like: $accountData = $this->getEntityManager() ->createQueryBuilder()->select('a, c') ->from('YourAccountBundle:Account', 'a') ->join('a.customers', 'c') // assuming there is a relationship like this ->where('a = :yourAccountManager') ->setParameter('yourAccountManager', $accountEntity) ->getQuery()->getResult(); Then use $accountData in your parent form. This will restrict the...

Doctrine OneByOne's and Date

php,symfony2,doctrine2,entity

Your entity class needs getters (and setter). class News { // ... /** * @ORM\Column(name="published_at", type="datetime") */ private $published_at; public function getPublished_at() { return $this->published_at; } } with this {{ news_item.published_at }} will call News::getPublished_at. (...) if not, and if foo is an object, check that getBar is a valid...

Doctrine persist entity with inverse relation not work

symfony2,doctrine2,entity

SOLVE: I can solve it. The code of my entities thats ok. I change the controller function. First I create the product object, set the providerRate to null and them persist it. After I create the providerRate object and set the product object. public function ajaxNewProductAction() { $request = $this->getRequest();...

JPA/Hibernate @IdClass Produces 'Identifier of an Instance was Altered'

java,hibernate,jpa,orm,entity

The reason for this error is due to changing the entity identifier of a managed entity. During the life-time of a PersistenceContext, there can be one and only one managed instance of any given entity. For this, you can't change an existing managed entity identifier. In you example, even if...

Autogenerated MVVM: Validation and INotifyPropertyChanged

wpf,database,mvvm,entity,auto-generate

This is too generic a question to be answered. "Is better to implement ... ?" : This depends on the application need . Ideally the Model has all the properties and the Viewmodel is just the place where you fill the Model and write the necessary business logic. Since you...