entities

Doctrine - Add default time stamp to entity like NOW()

*爱你&永不变心* 提交于 2019-11-27 16:04:18
问题 Following the Doctrine guidelines I understand how to set a default value for an Entity, but what if I wanted a date/time stamp? http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/faq.html My problem is my database has a default of NOW() on a field but when I use Doctrine to insert a record the values are null or blank but the rest of the insert happened. Also since Doctrine says to declare the default as a const, this also creates a problem. Suggestions? 回答1: Ok I found

Sf2 : using a service inside an entity

柔情痞子 提交于 2019-11-27 09:16:20
问题 i know this has been asked over and over again, i read the topics, but it's always focused on specific cases and i generally try to understand why its not best practise to use a service inside an entity. Given a very simple service : Class Age { private $date1; private $date2; private $format; const ym = "%y years and %m month" const ... // some DateTime()->diff() methods, checking, formating the entry formats, returning different period formats for eg. } and a simple entity : Class People {

Why do we need entity objects? [closed]

牧云@^-^@ 提交于 2019-11-27 09:08:18
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . I really need to see some honest, thoughtful debate on the merits of the currently accepted enterprise application design paradigm. I am not convinced that entity objects should exist. By entity objects I mean the typical things we tend to build for our applications, like

What is the difference between “LINQ to Entities”, “LINQ to SQL” and “LINQ to Dataset”

心不动则不痛 提交于 2019-11-27 09:07:00
问题 I've been working for quite a while now with LINQ. However, it remains a bit of a mystery what the real differences are between the mentioned flavours of LINQ. The successful answer will contain a short differentiation between them. What is the main goal of each flavor, what is the benefit, and is there a performance impact... P.S. I know that there are a lot of information sources out there, but I'm looking for a kind of a "cheat sheet" which instructs a newbie where to head for a specific

html entities in a javascript alert?

北城余情 提交于 2019-11-27 07:09:37
问题 I have a string coming from a XML (which I can't edit) and I'd like to print it trough an alert in javascript. Example of my string: This is à string And I need to print in an alert: This is à string is there a js html decode? 回答1: var encoded = "This is à string"; var decoded = $("<div/>").html(encoded).text(); alert(decoded); 回答2: you could put the string in a dom element and read it out again, even without jquery: https://stackoverflow.com/a/3700369/1986499 Edit by recent demand to include

Get array/list of entities from Doctrine

我的梦境 提交于 2019-11-27 06:59:03
问题 This is probably pretty simple, but I can't find a way to do this. Is there any way to get a list of class names of the entities that Doctrine manages? Something like: $entities = $doctrine->em->getEntities(); where $entities is an array with something like array('User', 'Address', 'PhoneNumber') etc... 回答1: I know this question is old, but in case someone still needs to do it (tested in Doctrine 2.4.0): $classes = array(); $metas = $entityManager->getMetadataFactory()->getAllMetadata();

How to make Nokogiri transparently return un/encoded Html entities untouched?

▼魔方 西西 提交于 2019-11-27 06:20:00
问题 How can I use Nokogiri with having html entities (like German umlauts) untouched? I.e.: # this is fine node = Nokogiri::HTML.fragment('<p>ö</p>') node.to_s # => '<p>ö</p>' # this is not node = Nokogiri::HTML.fragment('<p>ö</p>') node.to_s # => '<p>ö</p>' # this is what I need node = Nokogiri::HTML.fragment('<p>ö</p>') node.to_s # => '<p>ö</p>' I've tried to mess with both PARSE_OPTIONS and :save_with options but could not come up with a way to have Nokogiri just transparently behave like

Spacy annotation tool entities indices

懵懂的女人 提交于 2019-11-27 04:52:19
问题 How can I read my annotated data in Spacy? 1) My annotated data's form: "annotation": [ [ 79, 99, "Nom complet" ], 2) Annotated data's form in the script: "annotation": [ { "label": [ "Companies worked at" ], "points": [ { "start": 1749, "end": 1754, "text": "Oracle" } ] }, 3) How can I change this code that can read my annotated data? for line in lines: data = json.loads(line) text = data['text'] entities = [] for annotation in data['annotation']: #only a single point in text annotation.

Unescaping XML entities using XmlReader in .NET?

六眼飞鱼酱① 提交于 2019-11-27 02:54:11
问题 I'm trying to unescape XML entities in a string in .NET (C#), but I don't seem to get it to work correctly. For example, if I have the string AT&T , it should be translated to AT&T . One way is to use HttpUtility.HtmlDecode(), but that's for HTML. So I have two questions about this: Is it safe to use HttpUtility.HtmlDecode() for decoding XML entities? How do I use XmlReader (or something similar) to do this? I have tried the following, but that always returns an empty string: static string

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

浪尽此生 提交于 2019-11-27 00:41:49
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 the spotlight of the persistence unit? I have read Hibernate manual, http://docs.jboss.org/hibernate/stable/entitymanager/reference/en/html/configuration.html#setup-configuration-packaging I have also seen these SO questions How can I merge / extend persistence units from different JARs? define jpa entity classes outside of persistence.xml Programmatically loading Entity classes with JPA 2.0? I am