Search Results

Search found 32789 results on 1312 pages for 'object relational mapping'.

Page 14/1312 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Qt 4.6 Adding objects and sub-objects to QWebView window object (C++ & Javascript)

    - by Cor
    I am working with Qt's QWebView, and have been finding lots of great uses for adding to the webkit window object. One thing I would like to do is nested objects... for instance: in Javascript I can... var api = new Object; api.os = new Object; api.os.foo = function(){} api.window = new Object(); api.window.bar = function(){} obviously in most cases this would be done through a more OO js-framework. This results in a tidy structure of: >>>api ------------------------------------------------------- - api Object {os=Object, more... } - os Object {} foo function() - win Object {} bar function() ------------------------------------------------------- Right now I'm able to extend the window object with all of the qtC++ methods and signals I need, but they all have 'seem' to have to be in a root child of "window". This is forcing me to write a js wrapper object to get the hierarchy that I want in the DOM. >>>api ------------------------------------------------------- - api Object {os=function, more... } - os_foo function() - win_bar function() ------------------------------------------------------- This is a pretty simplified example... I want objects for parameters, etc... Does anyone know of a way to pass an child object with the object that extends the WebFrame's window object? Here's some example code of how I'm adding the object: mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QtGui/QMainWindow> #include <QWebFrame> #include "mainwindow.h" #include "happyapi.h" class QWebView; class QWebFrame; QT_BEGIN_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0); private slots: void attachWindowObject(); void bluesBros(); private: QWebView *view; HappyApi *api; QWebFrame *frame; }; #endif // MAINWINDOW_H mainwindow.cpp #include <QDebug> #include <QtGui> #include <QWebView> #include <QWebPage> #include "mainwindow.h" #include "happyapi.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { view = new QWebView(this); view->load(QUrl("file:///Q:/example.htm")); api = new HappyApi(this); QWebPage *page = view->page(); frame = page->mainFrame(); attachWindowObject(); connect(frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(attachWindowObject())); connect(api, SIGNAL(win_bar()), this, SLOT(bluesBros())); setCentralWidget(view); }; void MainWindow::attachWindowObject() { frame->addToJavaScriptWindowObject(QString("api"), api); }; void MainWindow::bluesBros() { qDebug() << "foo and bar are getting the band back together!"; }; happyapi.h #ifndef HAPPYAPI_H #define HAPPYAPI_H #include <QObject> class HappyApi : public QObject { Q_OBJECT public: HappyApi(QObject *parent); public slots: void os_foo(); signals: void win_bar(); }; #endif // HAPPYAPI_H happyapi.cpp #include <QDebug> #include "happyapi.h" HappyApi::HappyApi(QObject *parent) : QObject(parent) { }; void HappyApi::os_foo() { qDebug() << "foo called, it want's it's bar back"; }; I'm reasonably new to C++ programming (coming from a web and python background). Hopefully this example will serve to not only help other new users, but be something interesting for a more experienced c++ programmer to elaborate on. Thanks for any assistance that can be provided. :)

    Read the article

  • Mixing inheritance mapping strategies in NHibernate

    - by MylesRip
    I have a rather large inheritance hierarchy in which some of the subclasses add very little and others add quite a bit. I don't want to map the entire hierarchy using either "table per class hierarchy" or "table per subclass" due to the size and complexity of the hierarchy. Ideally I'd like to mix mapping strategies such that portions of the hierarchy where the subclasses add very little are combined into a common table a la "table per class hierarchy" and subclasses that add a lot are broken out into a separate table. Using this approach, I would expect to have 2 or 3 tables with very little wasted space instead of either 1 table with lots of fields that don't apply to most of the objects, or 20+ tables, several of which would have only a couple of columns. In the NHibernate Reference Documentation version 2.1.0, I found section 8.1.4 "Mixing table per class hierarchy with table per subclass". This approach switches strategies partway down the hierarchy by using: ... <subclass ...> <join ...> <property ...> ... </join> </subclass> ... This is great in theory. In practice, though, I found that the schema was too restrictive in what was allowed inside the "join" element for me to be able to accomplish what I needed. Here is the related part of the schema definition: <xs:element name="join"> <xs:complexType> <xs:sequence> <xs:element ref="subselect" minOccurs="0" /> <xs:element ref="comment" minOccurs="0" /> <xs:element ref="key" /> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="property" /> <xs:element ref="many-to-one" /> <xs:element ref="component" /> <xs:element ref="dynamic-component" /> <xs:element ref="any" /> <xs:element ref="map" /> <xs:element ref="set" /> <xs:element ref="list" /> <xs:element ref="bag" /> <xs:element ref="idbag" /> <xs:element ref="array" /> <xs:element ref="primitive-array" /> </xs:choice> <xs:element ref="sql-insert" minOccurs="0" /> <xs:element ref="sql-update" minOccurs="0" /> <xs:element ref="sql-delete" minOccurs="0" /> </xs:sequence> <xs:attribute name="table" use="required" type="xs:string" /> <xs:attribute name="schema" type="xs:string" /> <xs:attribute name="catalog" type="xs:string" /> <xs:attribute name="subselect" type="xs:string" /> <xs:attribute name="fetch" default="join"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="join" /> <xs:enumeration value="select" /> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="inverse" default="false" type="xs:boolean"> </xs:attribute> <xs:attribute name="optional" default="false" type="xs:boolean"> </xs:attribute> </xs:complexType> </xs:element> As you can see, this allows the use of "property" child elements or "component" child elements, but not both. It also doesn't allow for "subclass" child elements to continue the hierarchy below the point at which the strategy was changed. Is there a way to accomplish this?

    Read the article

  • Hibernate mapping to manage bidirectional relationship using intermediate table

    - by shikarishambu
    I have an object hierarchy that is as follows. Party inherited by Organization and Person Organization inherited by Customer, Vendor Person inherited by Contact In the database I have the following tables Party, Customer, Vendor, Contact. All of them have a corresponding row in Party table. Contact belongs to either Vendor or Customer. I have a field on the Contact table for org_party_id. However, since the organization can be either a Customer or Vendor I need to be able to look at different tables. Is there a way to map this in hibernate? Or, a better way to manage it in DB/ hibernate?

    Read the article

  • How to map a search object to a class with more fields with JPA annotations

    - by Moli
    Hi all, I'm a newbie with JPA. I need to map a search object to a table. The search object has only and id, name. The big object has more fileds id, name, adress and more. I use this as big object view plaincopy to clipboardprint? I use this as big object @Entity @Table(name="users") public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String name; private String adress; private String keywords; } //this is my search object @XXX public class UserSearch { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String name; } What annotations I need to use to map the search object to the table users? I'm using spring+struts2+hibernate+JPA. Help is appreciated! Thanks!

    Read the article

  • Inheritance Mapping Strategies with Entity Framework Code First CTP5: Part 2 – Table per Type (TPT)

    - by mortezam
    In the previous blog post you saw that there are three different approaches to representing an inheritance hierarchy and I explained Table per Hierarchy (TPH) as the default mapping strategy in EF Code First. We argued that the disadvantages of TPH may be too serious for our design since it results in denormalized schemas that can become a major burden in the long run. In today’s blog post we are going to learn about Table per Type (TPT) as another inheritance mapping strategy and we'll see that TPT doesn’t expose us to this problem. Table per Type (TPT)Table per Type is about representing inheritance relationships as relational foreign key associations. Every class/subclass that declares persistent properties—including abstract classes—has its own table. The table for subclasses contains columns only for each noninherited property (each property declared by the subclass itself) along with a primary key that is also a foreign key of the base class table. This approach is shown in the following figure: For example, if an instance of the CreditCard subclass is made persistent, the values of properties declared by the BillingDetail base class are persisted to a new row of the BillingDetails table. Only the values of properties declared by the subclass (i.e. CreditCard) are persisted to a new row of the CreditCards table. The two rows are linked together by their shared primary key value. Later, the subclass instance may be retrieved from the database by joining the subclass table with the base class table. TPT Advantages The primary advantage of this strategy is that the SQL schema is normalized. In addition, schema evolution is straightforward (modifying the base class or adding a new subclass is just a matter of modify/add one table). Integrity constraint definition are also straightforward (note how CardType in CreditCards table is now a non-nullable column). Another much more important advantage is the ability to handle polymorphic associations (a polymorphic association is an association to a base class, hence to all classes in the hierarchy with dynamic resolution of the concrete class at runtime). A polymorphic association to a particular subclass may be represented as a foreign key referencing the table of that particular subclass. Implement TPT in EF Code First We can create a TPT mapping simply by placing Table attribute on the subclasses to specify the mapped table name (Table attribute is a new data annotation and has been added to System.ComponentModel.DataAnnotations namespace in CTP5): public abstract class BillingDetail {     public int BillingDetailId { get; set; }     public string Owner { get; set; }     public string Number { get; set; } } [Table("BankAccounts")] public class BankAccount : BillingDetail {     public string BankName { get; set; }     public string Swift { get; set; } } [Table("CreditCards")] public class CreditCard : BillingDetail {     public int CardType { get; set; }     public string ExpiryMonth { get; set; }     public string ExpiryYear { get; set; } } public class InheritanceMappingContext : DbContext {     public DbSet<BillingDetail> BillingDetails { get; set; } } If you prefer fluent API, then you can create a TPT mapping by using ToTable() method: protected override void OnModelCreating(ModelBuilder modelBuilder) {     modelBuilder.Entity<BankAccount>().ToTable("BankAccounts");     modelBuilder.Entity<CreditCard>().ToTable("CreditCards"); } Generated SQL For QueriesLet’s take an example of a simple non-polymorphic query that returns a list of all the BankAccounts: var query = from b in context.BillingDetails.OfType<BankAccount>() select b; Executing this query (by invoking ToList() method) results in the following SQL statements being sent to the database (on the bottom, you can also see the result of executing the generated query in SQL Server Management Studio): Now, let’s take an example of a very simple polymorphic query that requests all the BillingDetails which includes both BankAccount and CreditCard types: projects some properties out of the base class BillingDetail, without querying for anything from any of the subclasses: var query = from b in context.BillingDetails             select new { b.BillingDetailId, b.Number, b.Owner }; -- var query = from b in context.BillingDetails select b; This LINQ query seems even more simple than the previous one but the resulting SQL query is not as simple as you might expect: -- As you can see, EF Code First relies on an INNER JOIN to detect the existence (or absence) of rows in the subclass tables CreditCards and BankAccounts so it can determine the concrete subclass for a particular row of the BillingDetails table. Also the SQL CASE statements that you see in the beginning of the query is just to ensure columns that are irrelevant for a particular row have NULL values in the returning flattened table. (e.g. BankName for a row that represents a CreditCard type) TPT ConsiderationsEven though this mapping strategy is deceptively simple, the experience shows that performance can be unacceptable for complex class hierarchies because queries always require a join across many tables. In addition, this mapping strategy is more difficult to implement by hand— even ad-hoc reporting is more complex. This is an important consideration if you plan to use handwritten SQL in your application (For ad hoc reporting, database views provide a way to offset the complexity of the TPT strategy. A view may be used to transform the table-per-type model into the much simpler table-per-hierarchy model.) SummaryIn this post we learned about Table per Type as the second inheritance mapping in our series. So far, the strategies we’ve discussed require extra consideration with regard to the SQL schema (e.g. in TPT, foreign keys are needed). This situation changes with the Table per Concrete Type (TPC) that we will discuss in the next post. References ADO.NET team blog Java Persistence with Hibernate book a { text-decoration: none; } a:visited { color: Blue; } .title { padding-bottom: 5px; font-family: Segoe UI; font-size: 11pt; font-weight: bold; padding-top: 15px; } .code, .typeName { font-family: consolas; } .typeName { color: #2b91af; } .padTop5 { padding-top: 5px; } .padTop10 { padding-top: 10px; } p.MsoNormal { margin-top: 0in; margin-right: 0in; margin-bottom: 10.0pt; margin-left: 0in; line-height: 115%; font-size: 11.0pt; font-family: "Calibri" , "sans-serif"; }

    Read the article

  • Class Mapping Error: 'T' must be a non-abstract type with a public parameterless constructor

    - by Amit Ranjan
    Hi, While mapping class i am getting error 'T' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method. Below is my SqlReaderBase Class public abstract class SqlReaderBase<T> : ConnectionProvider { #region Abstract Methods protected abstract string commandText { get; } protected abstract CommandType commandType { get; } protected abstract Collection<IDataParameter> GetParameters(IDbCommand command); **protected abstract MapperBase<T> GetMapper();** #endregion #region Non Abstract Methods /// <summary> /// Method to Execute Select Queries for Retrieveing List of Result /// </summary> /// <returns></returns> public Collection<T> ExecuteReader() { //Collection of Type on which Template is applied Collection<T> collection = new Collection<T>(); // initializing connection using (IDbConnection connection = GetConnection()) { try { // creates command for sql operations IDbCommand command = connection.CreateCommand(); // assign connection to command command.Connection = connection; // assign query command.CommandText = commandText; //state what type of query is used, text, table or Sp command.CommandType = commandType; // retrieves parameter from IDataParameter Collection and assigns it to command object foreach (IDataParameter param in GetParameters(command)) command.Parameters.Add(param); // Establishes connection with database server connection.Open(); // Since it is designed for executing Select statements that will return a list of results // so we will call command's execute reader method that return a Forward Only reader with // list of results inside. using (IDataReader reader = command.ExecuteReader()) { try { // Call to Mapper Class of the template to map the data to its // respective fields MapperBase<T> mapper = GetMapper(); collection = mapper.MapAll(reader); } catch (Exception ex) // catch exception { throw ex; // log errr } finally { reader.Close(); reader.Dispose(); } } } catch (Exception ex) { throw ex; } finally { connection.Close(); connection.Dispose(); } } return collection; } #endregion } What I am trying to do is , I am executine some command and filling my class dynamically. The class is given below: namespace FooZo.Core { public class Restaurant { #region Private Member Variables private int _restaurantId = 0; private string _email = string.Empty; private string _website = string.Empty; private string _name = string.Empty; private string _address = string.Empty; private string _phone = string.Empty; private bool _hasMenu = false; private string _menuImagePath = string.Empty; private int _cuisine = 0; private bool _hasBar = false; private bool _hasHomeDelivery = false; private bool _hasDineIn = false; private int _type = 0; private string _restaurantImagePath = string.Empty; private string _serviceAvailableTill = string.Empty; private string _serviceAvailableFrom = string.Empty; public string Name { get { return _name; } set { _name = value; } } public string Address { get { return _address; } set { _address = value; } } public int RestaurantId { get { return _restaurantId; } set { _restaurantId = value; } } public string Website { get { return _website; } set { _website = value; } } public string Email { get { return _email; } set { _email = value; } } public string Phone { get { return _phone; } set { _phone = value; } } public bool HasMenu { get { return _hasMenu; } set { _hasMenu = value; } } public string MenuImagePath { get { return _menuImagePath; } set { _menuImagePath = value; } } public string RestaurantImagePath { get { return _restaurantImagePath; } set { _restaurantImagePath = value; } } public int Type { get { return _type; } set { _type = value; } } public int Cuisine { get { return _cuisine; } set { _cuisine = value; } } public bool HasBar { get { return _hasBar; } set { _hasBar = value; } } public bool HasHomeDelivery { get { return _hasHomeDelivery; } set { _hasHomeDelivery = value; } } public bool HasDineIn { get { return _hasDineIn; } set { _hasDineIn = value; } } public string ServiceAvailableFrom { get { return _serviceAvailableFrom; } set { _serviceAvailableFrom = value; } } public string ServiceAvailableTill { get { return _serviceAvailableTill; } set { _serviceAvailableTill = value; } } #endregion public Restaurant() { } } } For filling my class properties dynamically i have another class called MapperBase Class with following methods: public abstract class MapperBase<T> where T : new() { protected T Map(IDataRecord record) { T instance = new T(); string fieldName; PropertyInfo[] properties = typeof(T).GetProperties(); for (int i = 0; i < record.FieldCount; i++) { fieldName = record.GetName(i); foreach (PropertyInfo property in properties) { if (property.Name == fieldName) { property.SetValue(instance, record[i], null); } } } return instance; } public Collection<T> MapAll(IDataReader reader) { Collection<T> collection = new Collection<T>(); while (reader.Read()) { collection.Add(Map(reader)); } return collection; } } There is another class which inherits the SqlreaderBaseClass called DefaultSearch. Code is below public class DefaultSearch: SqlReaderBase<Restaurant> { protected override string commandText { get { return "Select Name from vw_Restaurants"; } } protected override CommandType commandType { get { return CommandType.Text; } } protected override Collection<IDataParameter> GetParameters(IDbCommand command) { Collection<IDataParameter> parameters = new Collection<IDataParameter>(); parameters.Clear(); return parameters; } protected override MapperBase<Restaurant> GetMapper() { MapperBase<Restaurant> mapper = new RMapper(); return mapper; } } But whenever I tried to build , I am getting error 'T' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method. Even T here is Restaurant has a Parameterless Public constructor.

    Read the article

  • Retrieving Data related to a top-level object from parse.com using PHP

    - by Albeert Tw
    I am retrieve related data using parse.com and PHP I get the top-leve object without problems but I can't access related data. ([myRelation] => stdClass Object ( [__type] => Relation [className] => other)) Please refer to my code below: $className = "myClass"; $url = 'https://api.parse.com/1/classes/' . $className; $appId = 'xxxxxx'; $restKey = 'xxxxxxx'; $relatedParams = urlencode('include=people'); $rest = curl_init(); curl_setopt($rest, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($rest, CURLOPT_URL, $url .'/io1GzkzErH/'.$relatedParams); curl_setopt($rest, CURLOPT_HTTPGET, true); curl_setopt($rest, CURLOPT_RETURNTRANSFER, true); curl_setopt($rest, CURLOPT_HTTPHEADER, array("X-Parse-Application-Id: " . $appId, "X-Parse-REST-API-Key: " . $restKey, "Content-Type: application/json")); $response = curl_exec($rest); echo $response; I want to see related objects into myRelation. Current answer is: I get this answer: stdClass Object ( [Altres] => loremipsum. [Cartell] => stdClass Object ( [__type] => File [name] => f29efff4-5db1-451a-ab42-7569fbb955a7-cartell.jpg [url] => loremipsum.jpg ) [CartellURL] => [Categoria] => Comedia [Durada] => 120min [Estat] => Al teatre [Final] => stdClass Object ( [__type] => Date [iso] => 2014-06-18T22:00:00.000Z ) [Inici] => stdClass Object ( [__type] => Date [iso] => 2014-04-25T22:00:00.000Z ) [Nom] => Losers [Prioritat] => 0 [Sala] => loremipsum [Sinopsis] => loremipsum [TrailerURL] => loremipsum.com [URLEntrada] => loremipsum.com [URLProductora] => http://www.loremipsum.com [Visible] => 1 [createdAt] => 2014-05-20T12:01:06.094Z [objectId] => io1GzkzErH [people] => stdClass Object ( [__type] => Relation [className] => persones ) [updatedAt] => 2014-05-20T12:07:22.758Z ) loremipsum But I need to know what are in [people] = stdClass Object ( [__type] = Relation [className] = persones )

    Read the article

  • Triangle Strips and Tangent Space Normal Mapping

    - by Koarl
    Short: Do triangle strips and Tangent Space Normal mapping go together? According to quite a lot of tutorials on bump mapping, it seems common practice to derive tangent space matrices in a vertex program and transform the light direction vector(s) to tangent space and then pass them on to a fragment program. However, if one was using triangle strips or index buffers, it is a given that the vertex buffer contains vertices that sit at border edges and would thus require more than one normal to derive tangent space matrices to interpolate between in fragment programs. Is there any reasonable way to not have duplicate vertices in your buffer and still use tangent space normal mapping? Which one do you think is better: Having normal and tangent encoded in the assets and just optimize the geometry handling to alleviate the cost of duplicate vertices or using triangle strips and computing normals/tangents completely at run time? Thinking about it, the more reasonable answer seems to be the first one, but why might my professor still be fussing about triangle strips when it seems so obvious?

    Read the article

  • Actually utilizing relational databases for entity systems

    - by Marc Müller
    Recently I was researching several entity systems and obviously I came across T=Machine's fantastic articles on the subject. In Part 5 of the series the author uses a relational schema to explain how an entity system is built and works. Since reading this, I have been wondering whether or not actually using a compact SQL library would be fast enough for real-time usage in video games. Performance seems to be the main issue with a full blown SQL database for management of all entities and components. However, as mentioned in T=Machine's post, basically all access to data inside the SQLDB is done sequentlially by each system over each component. Additionally, using a library like SQLite, one could easily improve performance by storing the entity data exclusively in RAM to increase access speeds. Disregarding possible performance issues, using a SQL database, in my opinion, would allow for a very intuitive implementation of entity systems and bring a long certain other benefits like easy de/serialization of game states and consistency checks like the uniqueness of entity IDs. Edit for clarification: The main question was whether using a SQL database for the actual entity management (not just storing the game state on the disk) in a real-time game would still yield a framerate appropriate for a game or even if someone is aware of projects that demonstrate SQL in a video game.

    Read the article

  • Can an object oriented program be seen as a Finite State Machine?

    - by Peretz
    This might be a philosophical/fundamental question, but I just want to clarify it. In my understanding a Finite State Machine is a way of modeling a system in which the system's output will not only depend on the current inputs, but also the current state of the system. Additionally, as the name suggests it, a finite state machine can be segmented in a finite N number of states with its respective state and behavior. If this is correct, shouldn't every single object with data and function members be a state in our object oriented model, making any object oriented design a finite state machine? If that is not the interpretation of a FSM in object design, what exactly people mean when they implement a FSM in software? am I missing something? Thanks

    Read the article

  • Breaking up a large PHP object used to abstract the database. Best practices?

    - by John Kershaw
    Two years ago it was thought a single object with functions such as $database->get_user_from_id($ID) would be a good idea. The functions return objects (not arrays), and the front-end code never worries about the database. This was great, until we started growing the database. There's now 30+ tables, and around 150 functions in the database object. It's getting impractical and unmanageable and I'm going to be breaking it up. What is a good solution to this problem? The project is large, so there's a limit to the extent I can change things. My current plan is to extend the current object for each table, then have the database object contain these. So, the above example would turn into (assume "user" is a table) $database->user->get_user_from_id($ID). Instead of one large file, we would have a file for every table.

    Read the article

  • Questioning one of the arguments for dependency injection: Why is creating an object graph hard?

    - by oberlies
    Dependency injection frameworks like Google Guice give the following motivation for their usage (source): To construct an object, you first build its dependencies. But to build each dependency, you need its dependencies, and so on. So when you build an object, you really need to build an object graph. Building object graphs by hand is labour intensive (...) and makes testing difficult. But I don't buy this argument: Even without dependency injection, I can write classes which are both easy to instantiate and convenient to test. E.g. the example from the Guice motivation page could be rewritten in the following way: class BillingService { private final CreditCardProcessor processor; private final TransactionLog transactionLog; // constructor for tests, taking all collaborators as parameters BillingService(CreditCardProcessor processor, TransactionLog transactionLog) { this.processor = processor; this.transactionLog = transactionLog; } // constructor for production, calling the (productive) constructors of the collaborators public BillingService() { this(new PaypalCreditCardProcessor(), new DatabaseTransactionLog()); } public Receipt chargeOrder(PizzaOrder order, CreditCard creditCard) { ... } } So there may be other arguments for dependency injection (which are out of scope for this question!), but easy creation of testable object graphs is not one of them, is it?

    Read the article

  • Is there an alternative to the term "calling object"?

    - by ybakos
    Let's suppose you've got a class defined (in pseudocode): class Puppy { // ... string sound = "Rawr!"; void bark() { print(sound); } } And say, given a Puppy instance, you call it's bark() method: Puppy p; p.bark(); Notice how bark() uses the member variable sound. In many contexts, I've seen folks describe sound as the member variable of the "calling object." My question is, what's a better term to use than "calling object?" To me, the object is not doing any calling. We know that member functions are in a way just functions with an implicit this or self parameter. I've come up with "receiving object," or "message recipient," which makes sense if you're down with the "messaging" paradigm. Do any of you happy hackers have a term that you like to use? I feel it should mean "the object upon which a method is called" and TOUWAMIC just doesn't cut it.

    Read the article

  • spl_object_hash for PHP < 5.2 (unique ID for object instances)

    - by Rowan
    I'm trying to get unique IDs for object instances in PHP 5+. The function, spl_object_hash() is available from PHP 5.2 but I'm wondering if there's a workaround for older versions. There are a couple of functions in the comments on php.net but they're not working for me. The first (simplified): function spl_object_hash($object){ if (is_object($object)){ return md5((string)$object); } return null; } does not work with native objects (such as DOMDocument), and the second: function spl_object_hash($object){ if (is_object($object)){ ob_start(); var_dump($object); $dump = ob_get_contents(); ob_end_clean(); if (preg_match('/^object\(([a-z0-9_]+)\)\#(\d)+/i', $dump, $match)) { return md5($match[1] . $match[2]); } } return null; } looks like it could be a major performance buster! Does anybody have anything up their sleeve?

    Read the article

  • PHP: How do I access child properties from a method in a base object?

    - by Nick
    I'd like for all of my objects to be able to return a JSON string of themselves. So I created a base class for all of my objects to extend, with an AsJSON() method: class BaseObject { public function AsJSON() { $JSON=array(); foreach ($this as $key = $value) { if(is_null($value)) continue; $JSON[$key] = $value; } return json_encode($JSON); } } And then extend my child classes from that: class Package extends BaseObject { ... } So in my code, I expect to do this: $Box = new Package; $Box-SetID('123'); $Box-SetName('12x8x6'); $Box-SetBoxX('12'); $Box-SetBoxY('8'); $Box-SetBoxZ('6'); echo $Box-AsJSON(); But the JSON string it returns only contains the BaseClass's properties, not the child properties. How do I modify my AsJSON() function so that $this refers to the child's properties, not the parent's?

    Read the article

  • Why "object reference not set to an instance of an object" doesn't tell us which object?

    - by Saeed Neamati
    We're launching a system, and we sometimes get the famous exception NullReferenceException with the message Object reference not set to an instance of an object. However, in a method where we have almost 20 objects, having a log which says an object is null, is really of no use at all. It's like telling you, when you are the security agent of a seminar, that a man among 100 attendees is a terrorist. That's really of no use to you at all. You should get more information, if you want to detect which man is the threatening man. Likewise, if we want to remove the bug, we do need to know which object is null. Now, something has obsessed my mind for several months, and that is: Why .NET doesn't give us the name, or at least the type of the object reference, which is null?. Can't it understand the type from reflection or any other source? Also, what are the best practices to understand which object is null? Should we always test nullability of objects in these contexts manually and log the result? Is there a better way?

    Read the article

  • Associating an object with another object for GC clearup

    - by thecoop
    Is there any way of associating an object instance (object A) with a second object (object B) in a generalised way, so that when B gets collected A becomes eligable for collection? The same behaviour that would happen if B had an instance variable pointing to A, but without explicitly changing the class definition of B, and being able to do this in a dynamic way? The same sort of effect could be done by using the Component.Disposed event in a funky way, but I don't want to make B disposable EDIT I'm basically creating a cache of objects that are associated with a single 'root' object, and I don't want the cache to be static, as there can be lots of root objects using different caches, so lots of memory will be used up when a root object is no longer used but the cached objects are still around. So, I want a collection of cached objects to be associated with each 'root' object, without changing the root object definition. Sort of like metadata of an extra object reference attached to each root object instance. That way, each collection will get collected when the root object is collected, and not hang around like they would if a static cache was used.

    Read the article

  • Fluent NHibernate join table mapping

    - by Rusty
    Reverse engineering an existing database to map with N-Hibernate using Fluent N-Hibernate. How can I map this? Address table Id Address1 Address2 Person table Id First Last Types Id TypeName PersonAddress table (A person can have home, business etc addresses) Id PersonId (Id from person table) AddressId (Id from address table) TypeId (Id from types lookup table HOME, BUSINESS etc..) Any help would be great. Thanks

    Read the article

  • Fluent Nhibernate - Mapping two entities to same table

    - by Andy
    Hi, I'm trying to map two domain entities to the same table. We're doing a smart entity for our domain model, so we have the concept of an Editable Address and a readonly Address. I have both mapped using Classmaps, and everything seems to go fine until we try to export the schema using the SchemaExport class from NHibernate. It errors out saying the table already exists. I assume it's something simple that I'm just not seeing. Any ideas? Thanks

    Read the article

  • Fluent composite foreign key mapping

    - by Fionn
    Hi, I wonder if this is possible to map the following with fluent nhibernate: A document table and a document_revision table will be the target tables. The document_revision table should have a composite unique key consisting of the document_id and the revision number (where the document_id is also the foreign key to the document table). class Document { Guid Id; //other members omitted } class DocumentRevision { Guid document_id; //Part one of the primary key and also foreign key to Document.Id int revision; //Part two of the primary key //other members omitted }

    Read the article

  • (fluent) nhibernate conditional table mapping strategy

    - by grenade
    I have no control over database schema and have the following (simplified) table structure: CityProfile Id Name CountryProfile Id Name RegionProfile Id Name I have a .Net enum and class encapsulating the lot: public enum Scope { Region, Country, City } public class Profile { public Scope Scope { get; set; } public int Id { get; set; } public string Name { get; set; } } I am looking for a mechanism that allows me to map to the correct table, something like: public class ProfileMap : ClassMap<Profile> { public ProfileMap() { switch (x => x.Scope) { // <--Invalid code here! case Scope.City: Table("CityProfile"); break; case Scope.Country: Table("CountryProfile"); break; case Scope.Region: Table("RegionProfile"); break; } Id(x => x.Id); Map(x => x.Name); } } Or have I approached this wrong?

    Read the article

  • Mapping a child collection without indexing based on database primary key or using bag

    - by Colin Bowern
    I have a existing parent-child relationship I am trying to map in Fluent Nhibernate: [RatingCollection] -- [Rating] Rating Collection has: ID (database generated ID) Code Name Rating has: ID (database generated id) Rating Collection ID Code Name I have been trying to figure out which permutation of HasMany makes sense here. What I have right now: HasMany<Rating>(x => x.Ratings) .WithTableName("Rating") .KeyColumnNames.Add("RatingCollectionId") .Component(c => { c.Map(x => x.Code); c.Map(x => x.Name); ); It works from a CRUD perspective but because it's a bag it ends up deleting the rating contents any time I try to do a simple update / insert to the Ratings property. What I want is an indexed collection but not using the database generated ID (which is in the six digit range right now). Any thoughts on how I could get a zero-based indexed collection (so I can go entity.Ratings[0].Name = "foo") which would allow me to modify the collection without deleting/reinserting it all when persisting?

    Read the article

  • NIS password mapping question

    - by papoyan
    I have NIS server with user "techsupport", which has uid/gid = 517 I've configured NIS and NFS on that server, as well as NFS/NIS client on the remote web server. Now I need to techsupport user to be able to login to web server using techsupport username, but HAVE root privileges. I need this, so I can easily track, which support agent doing what on the web server. Everything works fine, when from NIS server, I ssh to the web server with tech support user nisserver# ssh [email protected] I can authenticate against the NIS server just fine, and my home directory that is on NIS server, get's mounted on web server just fine. The Only two problems I have are : my GID on web server is webserver# id uid=517(techsupport) gid=517(client_jonny) groups=517(client_jonny) (as you can see, that it picked up gid of a client that exists on the web server, since it's same number) I need to make sure, that my "techsupport" user has ROOT privileges. How can I achieve this? I remember that I've seen identical results elsewhere, but LDAP was used, is there a way to achieve this with NIS/NFS setup? Thank you in advance,

    Read the article

  • Hibernate mapping, on a unmapped class

    - by Jan
    Hi, I' ve got 2 tables... Challenge and ChallengeYear, ChallengeYear is only to create a list of years in challenge. I only want to make Challenge an entity, containing a list of List years. Is this possible? I've looked in to @SecondaryTable together with @JoinColumn and @OneToMany, but neither of those can do the trick, or i am overlooking something. Can someone help me? Greetings, Jan

    Read the article

  • nhibernate : One to One mapping

    - by frosty
    I have the following map. I wish to map BasketItem to the class "Product". So basically when i iterate thru the basket i can get the product name <class name="BasketItem" table="User_Current_Basket"> <id name="Id" type="Int32" column="Id" unsaved-value="0"> <generator class="identity"/> </id> <property name="ProductId" column="Item_ID" type="Int32"/> <one-to-one name="Product" class="Product"></one-to-one> </class> How do specifiy that product should match BasketItem.ProductId with Product.Id Also i've read that i should avoid one-to-one and just use one-to-many? If i was to do that how do i ensure i just get one product and not a collection.

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >