entities

LINQ .Take() returns more elements than requested

断了今生、忘了曾经 提交于 2019-12-02 20:38:43
We have a simple LINQ-to-Entities query that should return a specific number of elements from particular page. The example of the request can be: var query = from r in records orderby r.createdDate descending select new MyObject() { ... }; //Parameters: pageId = 8, countPerPage = 10 List<MyObject> list = query.Skip(pageId * countPerPage).Take(countPerPage); The above example works great in most of the cases, but sometimes the list has more than 10 elements. This doesn't seem to be always true and depends from the database data. For example, when we request the page 10 and pass countPerPage as

how to sort an entity's arrayCollection in symfony2

丶灬走出姿态 提交于 2019-12-02 20:07:07
I have an entity "container" with this property /** * @ORM\OneToMany(targetEntity="BizTV\ContentManagementBundle\Entity\Content", mappedBy="container") */ private $content; the property is an array collection... public function __construct() { $this->content = new \Doctrine\Common\Collections\ArrayCollection(); } ...with these two standard methods /** * Add content * * @param BizTV\ContentManagementBundle\Entity\Content $content */ public function addContent(\BizTV\ContentManagementBundle\Entity\Content $content) { $this->content[] = $content; } /** * Get content * * @return Doctrine\Common

What Belongs to the Aggregate Root

柔情痞子 提交于 2019-12-02 14:30:36
This is a practical Domain Driven Design question: Conceptually, I think I get Aggregate roots until I go to define one. I have an Employee entity, which has surfaced as an Aggregate root. In the Business, some employees can have work-related Violations logged against them: Employee-----*Violations Since not all Employees are subject to this, I would think that Violations would not be a part of the Employee Aggregate, correct? So when I want to work with Employees and their related violations, is this two separate Repository interactions by some Service? Lastly, when I add a Violation, is that

CDI Injection in Hibernate Entities

Deadly 提交于 2019-12-01 22:40:51
问题 We are using CDI(JSR 299) in our application (JSF2/Seam3.0/Hibernate 3.5.6/GlassFish 3.1.1) While we are unable to inject resources(Helper POJOs) in our managed beans using @Inject, we cannot do the same in our Hibernate Entity classes. We have a base entity class(@MappedSuperclass) that all entity objects derive from. CDI injection fails in both classes. @MappedSuperclass public class BaseBusinessObject implements Serializable { @Inject private TestClass testClass; //FAILS } @Entity

Case with doctrine2, symfony2 and postgresql entities

一曲冷凌霜 提交于 2019-12-01 18:32:28
I have a problem with doctrine2 in symfony2 app with postgres database. I get error: SQLSTATE[3F000]: Invalid schema name: 7 ERROR: schema "main" does not exist Problem is that my schema is Main not main. When I rename it, similar thing happends for table relation: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "main.brand_brandid_seq" does not exist Problem is case sensitivity and I guess maybe it have something to do with quoting or some doctrine configuration. Entity: namespace MyB\Entity; /** * MyB\Entity\Brand * * @orm:Table(name="Main.Brand") * @orm:Entity */ class Brand { /** *

Doctrine Mapping in Symfony2 using YAML

孤街醉人 提交于 2019-12-01 05:31:12
问题 I have a question regarding YAML configuration of Doctrine in Symfony2. I have created an entity via "doctrine:generate:entity", and chose YAML as the mapping format. This didn't add any metadata on ../Entity/"MyEntity".php, which would allow me to update or create my schema. As an example, if I run ./app/console doctrine:schema:create it fails, saying: [RuntimeException] Bundle "MySuperBundle" does not contain any mapped entities. My automapping is already set to "true". If I choose to use

Android string encoding and html entities converting

馋奶兔 提交于 2019-12-01 03:04:18
There is a String in Android Java. How do I change it to another given encoding and replace HTML-entities such as &amp; with & ? This is so that international symbols can be displayed correctly. to decode Html String you can use Html.fromHtml() like Html.fromHtml((String) htmlCode).toString(); if you want reverse than you can use TextUtils.htmlEncode() 来源: https://stackoverflow.com/questions/17643512/android-string-encoding-and-html-entities-converting

Java - convert named html entities to numbered xml entities

馋奶兔 提交于 2019-11-30 20:19:23
I'm looking to convert an html block that contains html named entities to an xml compliant block that uses numbered xml entities while leaving all html tag elements in place. This is the basic idea illustrated via test: @Test public void testEvalHtmlEntitiesToXmlEntities() { String input = "<a href=\"test.html\">link </a>"; String expected = "<a href=\"test.html\">link </a>"; String actual = SomeUtil.eval(input); Assert.assertEquals(expected, actual); } Is anyone aware of a Class that provides this functionality? I can write a regex to iterate through non element matches and do: xlmString +=

How to parse badly formed XML in Java?

余生长醉 提交于 2019-11-30 19:20:08
I have XML that I need to parse but have no control over the creation of. Unfortunately it's not very strict XML and contains things like: <mytag>This won't parse & contains an ampersand.</mytag> The javax.xml.stream classes don't like this at all, and rightly error with: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[149,50] Message: The entity name must immediately follow the '&' in the entity reference. How can I work around this? I can't change the XML, so I guess I need an error-tolerant parser. My preference would be for a fix that doesn't require too much disruption to

UserInfo Dictionaries on CoreData

老子叫甜甜 提交于 2019-11-30 18:17:57
What does this part of Apple core data documentation means? User Info Dictionaries Many of the elements in a managed object model—entities, attributes, and relationships—have an associated user info dictionary. You can put whatever information you want into a user info dictionary, as key-value pairs. Common information to put into the user info dictionary includes version details for an entity, and values used by the predicate for a fetched property. I understand that by default entities have that dictionary, but I'm not able to find find userInfo on coredata entities or attributes. Get the