Search Results

Search found 9916 results on 397 pages for 'entity component'.

Page 84/397 | < Previous Page | 80 81 82 83 84 85 86 87 88 89 90 91  | Next Page >

  • .LazyInitializationException when adding to a list that is held within a entity class using hibernat

    - by molleman
    Right so i am working with hibernate gilead and gwt to persist my data on users and files of a website. my users have a list of file locations. i am using annotations to map my classes to the database. i am getting a org.hibernate.LazyInitializationException when i try to add file locations to the list that is held in the user class. this is a method below that is overridden from a external file upload servlet class that i am using. when the file uploads it calls this method. the user1 is loaded from the database elsewhere. the exception occurs at user1.getFileLocations().add(fileLocation); . i dont understand it really at all.! any help would be great. the stack trace of the error is below public String executeAction(HttpServletRequest request, List<FileItem> sessionFiles) throws UploadActionException { for (FileItem item : sessionFiles) { if (false == item.isFormField()) { try { YFUser user1 = (YFUser)getSession().getAttribute(SESSION_USER); // This is the location where a file will be stored String fileLocationString = "/Users/Stefano/Desktop/UploadedFiles/" + user1.getUsername(); File fl = new File(fileLocationString); fl.mkdir(); // so here i will create the a file container for my uploaded file File file = File.createTempFile("upload-", ".bin",fl); // this is where the file is written to disk item.write(file); // the FileLocation object is then created FileLocation fileLocation = new FileLocation(); fileLocation.setLocation(fileLocationString); //test System.out.println("file path = "+file.getPath()); user1.getFileLocations().add(fileLocation); //the line above is where the exception occurs } catch (Exception e) { throw new UploadActionException(e.getMessage()); } } removeSessionFileItems(request); } return null; } //This is the class file for a Your Files User @Entity @Table(name = "yf_user_table") public class YFUser implements Serializable,ILightEntity { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "user_id",nullable = false) private int userId; @Column(name = "username") private String username; @Column(name = "password") private String password; @Column(name = "email") private String email; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "USER_FILELOCATION", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "locationId") }) private List<FileLocation> fileLocations = new ArrayList<FileLocation>() ; public YFUser(){ } public int getUserId() { return userId; } private void setUserId(int userId) { this.userId = userId; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public List<FileLocation> getFileLocations() { if(fileLocations ==null){ fileLocations = new ArrayList<FileLocation>(); } return fileLocations; } public void setFileLocations(List<FileLocation> fileLocations) { this.fileLocations = fileLocations; } /* public void addFileLocation(FileLocation location){ fileLocations.add(location); }*/ @Override public void addProxyInformation(String property, Object proxyInfo) { // TODO Auto-generated method stub } @Override public String getDebugString() { // TODO Auto-generated method stub return null; } @Override public Object getProxyInformation(String property) { // TODO Auto-generated method stub return null; } @Override public boolean isInitialized(String property) { // TODO Auto-generated method stub return false; } @Override public void removeProxyInformation(String property) { // TODO Auto-generated method stub } @Override public void setInitialized(String property, boolean initialised) { // TODO Auto-generated method stub } @Override public Object getValue() { // TODO Auto-generated method stub return null; } } @Entity @Table(name = "fileLocationTable") public class FileLocation implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "locationId", updatable = false, nullable = false) private int ieId; @Column (name = "location") private String location; /* private List uploadedUsers = new ArrayList(); */ public FileLocation(){ } public int getIeId() { return ieId; } private void setIeId(int ieId) { this.ieId = ieId; } public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } /* public List getUploadedUsers() { return uploadedUsers; } public void setUploadedUsers(List<YFUser> uploadedUsers) { this.uploadedUsers = uploadedUsers; } public void addUploadedUser(YFUser user){ uploadedUsers.add(user); } */ } Apr 2, 2010 11:33:12 PM org.hibernate.LazyInitializationException <init> SEVERE: failed to lazily initialize a collection of role: com.example.client.YFUser.fileLocations, no session or session was closed org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.example.client.YFUser.fileLocations, no session or session was closed at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380) at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365) at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:205) at org.hibernate.collection.PersistentBag.add(PersistentBag.java:297) at com.example.server.TestServiceImpl.saveFileLocation(TestServiceImpl.java:132) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:174) at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224) at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) at javax.servlet.http.HttpServlet.service(HttpServlet.java:713) at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488) Apr 2, 2010 11:33:12 PM net.sf.gilead.core.PersistentBeanManager clonePojo INFO: Third party instance, not cloned : org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.example.client.YFUser.fileLocations, no session or session was closed

    Read the article

  • Self-reference entity in Hibernate

    - by Marco
    Hi guys, I have an Action entity, that can have other Action objects as child in a bidirectional one-to-many relationship. The problem is that Hibernate outputs the following exception: "Repeated column in mapping for collection: DbAction.childs column: actionId" Below the code of the mapping: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="DbAction" table="actions"> <id name="actionId" type="short" /> <property not-null="true" name="value" type="string" /> <set name="childs" table="action_action" cascade="all-delete-orphan"> <key column="actionId" /> <many-to-many column="actionId" unique="true" class="DbAction" /> </set> <join table="action_action" inverse="true" optional="false"> <key column="actionId" /> <many-to-one name="parentAction" column="actionId" not-null="true" class="DbAction" /> </join> </class> </hibernate-mapping>

    Read the article

  • Deleting JPA entity containing @CollectionOfElements throws ConstraintViolationException

    - by Lyle
    I'm trying to delete entities which contain lists of Integer, and I'm getting ConstraintViolationExceptions because of the foreign key on the table generated to hold the integers. It appears that the delete isn't cascading to the mapped collection. I've done quite a bit of searching, but all of the examples I've seen on how to accomplish this are in reference to a mapped collection of other entities which can be annotated; here I'm just storing a list of Integer. Here is the relevant excerpt from the class I'm storing: @Entity @Table(name="CHANGE_IDS") @GenericGenerator( name = "CHANGE_ID_GEN", strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator", parameters = { @Parameter(name="sequence_name", value="course_changes_seq"), @Parameter(name="increment_size", value="5000"), @Parameter(name=" optimizer", value="pooled") } ) @NamedQueries ({ @NamedQuery( name="Changes.getByStatus", query= "SELECT c " + "FROM DChanges c " + "WHERE c.status = :status "), @NamedQuery( name="Changes.deleteByStatus", query= "DELETE " + "FROM Changes c " + "WHERE c.status = :status ") }) public class Changes { @Id @GeneratedValue(generator="CHANGE_ID_GEN") @Column(name = "ID") private final long id; @Enumerated(EnumType.STRING) @Column(name = "STATUS", length = 20, nullable = false) private final Status status; @Column(name="DOC_ID") @org.hibernate.annotations.CollectionOfElements @org.hibernate.annotations.IndexColumn(name="DOC_ID_ORDER") private List<Integer> docIds; } I'm deleting the Changes objects using a @NamedQuery: final Query deleteQuery = this.entityManager.createNamedQuery("Changes.deleteByStatus"); deleteQuery.setParameter("status", Status.POST_FLIP); final int deleted = deleteQuery.executeUpdate(); this.logger.info("Deleted " + deleted + " POST_FLIP Changes");

    Read the article

  • SelectMany in Linq to entity

    - by Brazeta
    I was looking at some examples in microsoft site about linq and I see an example that I need to modify! http://msdn.microsoft.com/en-us/vcsharp/aa336758.aspx#SelectManyCompoundfrom3 public void Linq16() { List customers = GetCustomerList(); var orders = from c in customers from o in c.Orders where o.OrderDate >= new DateTime(1998, 1, 1) select new { c.CustomerID, o.OrderID, o.OrderDate }; ObjectDumper.Write(orders); } Insted of having a select that retrives the CustomerID, OrderID and OrderDate I want to select the CustomerID and a System.Collection.Generic.List that contains all the orders for that user! Essentially I want to group my orders by CustomerID, but i noticed that linq to entity does not allow a .ToList(object) inside the select. I want something like this... List customers = GetCustomerList(); var orders = from c in customers from o in c.Orders where o.OrderDate >= new DateTime(1998, 1, 1) select new xpto { TheCostumerID = c.CustomerID, CostumerOrders = o.Select(i=>i.OrderID).ToList(), }; ...but the .ToList() is a big problem, at least for me. I'm trying to find out the solution for that but so far I have acomplished nothing! Please help me.

    Read the article

  • Binding DataGridComboBoxColumn to a one to many entity framework relation

    - by Cristian
    I have two tables in the model, one table contains entries related to the other table in a one to many relations, for example: Table User ID Name Table Comments ID UserID Title Text I want to show a datagrid in a WPF window with two columns, one text column with the User name and another column with a combobox showing all the comments made by the user. The datagrid definition is like this: <DataGrid AutoGenerateColumns="False" [layout options...] Name="dataGrid1" ItemsSource="{Binding}"> <DataGrid.Columns> <DataGridTextColumn Header="Name" Binding="{Binding Path=Name}"/> <DataGridComboBoxColumn Header="Comments" SelectedValueBinding="{Binding Path=UserID}" SelectedValuePath="ID" DisplayMemberPath="Title" ItemsSource="{Binding Path=Comments}" /> </DataGrid.Columns> </DataGrid> in the code I assign the DataContext like this: dataGrid1.DataContext = entities.Users; The entity User has a property named Comments that leads to all the comments made by the user. The queries are returning data and the user names are shown but the combobox is not being filled. May be the approach is totally wrong or I'm just missing a very simple point here, I'm opened to learn better methods to do this. Thanks

    Read the article

  • JPA - Setting entity class property from calculated column?

    - by growse
    I'm just getting to grips with JPA in a simple Java web app running on Glassfish 3 (Persistence provider is EclipseLink). So far, I'm really liking it (bugs in netbeans/glassfish interaction aside) but there's a thing that I want to be able to do that I'm not sure how to do. I've got an entity class (Article) that's mapped to a database table (article). I'm trying to do a query on the database that returns a calculated column, but I can't figure out how to set up a property of the Article class so that the property gets filled by the column value when I call the query. If I do a regular "select id,title,body from article" query, I get a list of Article objects fine, with the id, title and body properties filled. This works fine. However, if I do the below: Query q = em.createNativeQuery("select id,title,shorttitle,datestamp,body,true as published, ts_headline(body,q,'ShortWord=0') as headline, type from articles,to_tsquery('english',?) as q where idxfti @@ q order by ts_rank(idxfti,q) desc",Article.class); (this is a fulltext search using tsearch2 on Postgres - it's a db-specific function, so I'm using a NativeQuery) You can see I'm fetching a calculated column, called headline. How do I add a headline property to my Article class so that it gets populated by this query? So far, I've tried setting it to be @Transient, but that just ends up with it being null all the time.

    Read the article

  • Core Data - Entity Relationships Not Working as expected

    - by slimms
    I have set up my data model in xcode like so EntityA AttA1 AttA2 EntityB AttB1 AttB2 AttB3 I then set up the relationships EntityA Name: rlpToEntityB Destination: EntityB Inverse: rlpToEntityA To Many: Checked EntityB Name: rlpToEntityA Destination: EntityA Inverse: rlpToEntityB To Many: UnChecked i.e. relationship between the two where Each one of EntityA can have many EntityB's It is my understanding that if i fetch a subset of EntityB's I can then retrieve the values for the related EntityA's. I have this working so that i can retrieve the EntityB values using NSManagedObject *objMO = [fetchedResultsController objectAtIndexPath:indexPath]; strValueFromEntityB = [objMO valueForKey:@"AttB1"]; However, if I try to retrieve a related value from EntityA by doing the following strValueFromEntityA = [objMO valueForKey:@"AttA1"]; I get the error "The entity EntityB is not Key value coding-compliant for the key Atta1" Not surprisingly i suppose if i switch things around to fetch from EntityA i cannot access attributes of EntityB So it appears the defined relationshipare being ignored. Can anyone spot what i am doing wrong? I confess im very new to iPhone programming and especially to Core Data so please go easy on me and provide verbose explanations or point me in the direction a specific resource. I have downloaded the apple sample apps (Core Data Books, Top Songs and recipes) but I still can't work this out. Thanks in advance, Nev.

    Read the article

  • How to associate static entity instances in a Session without database retrieval

    - by Michael Hedgpeth
    I have a simple Result class that used to be an Enum but has evolved into being its own class with its own table. public class Result { public static readonly Result Passed = new Result(StatusType.Passed) { Id = [Predefined] }; public static readonly Result NotRun = new Result(StatusType.NotRun) { Id = [Predefined] }; public static readonly Result Running = new Result(StatusType.Running) { Id = [Predefined] }; } Each of these predefined values has a row in the database at their predefined Guid Id. There is then a failed result that has an instance per failure: public class FailedResult : Result { public FailedResult(string description) : base(StatusType.Failed) { . . . } } I then have an entity that has a Result: public class Task { public Result Result { get; set; } } When I save a Task, if the Result is a predefined one, I want NHibernate to know that it doesn't need to save that to the database, nor does it need to fetch it from the database; I just want it to save by Id. The way I get around this is when I am setting up the session, I call a method to load the static entities: protected override void OnSessionOpened(ISession session) { LockStaticResults(session, Result.Passed, Result.NotRun, Result.Running); } private static void LockStaticResults(ISession session, params Result[] results) { foreach (var result in results) { session.Load(result, result.Id); } } The problem with the session.Load method call is it appears to be fetching to the database (something I don't want to do). How could I make this so it does not fetch the database, but trusts that my static (immutable) Result instances are both up to date and a part of the session?

    Read the article

  • SQL, MVC, Entity Framework

    - by Anthony
    Hi Im using the above technologies and have ran into what I presume is a design issue I have made. I have an Artwork table in my DB and have been able to add art (I now think of these as Digital Products) to a shopping cart + CartLine table fine. The system I have that adds art to galleries and user accounts etc works fine. Now the client wants to sell T-shirts, Mugs and Pens etc, 'HardwareProducts' so I have created a 'HardwareProducts' table. Now I have two different product types in two tables. I use GUID's as the PK's in both the HardwareProducts table and Artwork table. When a customer adds an item to their cart I store the GUID in the ProductID column in the CartItems table. The issue is the database will not know which table to reference when I bring the LineItem object up through my ORM to the front end. In OOP I can see how you would have a base class of Product, and then a DigitalProduct class and HardwareProduct class drived from it, but how do you model this in SQL Server and the Entity Framework please, or is there another way?

    Read the article

  • Migrating from a single entity to an abstract parent entity with child entities, NSEntityMigrationPolicy not called.

    - by Jimmy Selgen Nielsen
    Hi. I'm trying to upgrade my current application to use an abstract parent entity, with specialized sub entities. I've created a custom NSEntityMigrationPolicy, and in the mapping model I've set the Custom Policy to the name of my class. I'm initializing my persistent store like this, which should be fairly standard : NSError *error=nil; persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]]; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, nil]; if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) { NSLog(@"Error adding persistent store : %@",[error description]); NSAssert(error==nil,[error localizedDescription]); } When i run the app i get the following error : Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The operation couldn’t be completed. (Cocoa error 134140.)' [error userInfo] contains "reason=Can't find mapping model for migration" I've verified that version 1 of the data model will open, and if i set NSInferMappingModelAutomaticallyOption i get a migration, although my entities are not migrated correctly (as expected). I've verified that the mapping model (cdm) is in the application bundle, but somehow it refuses to find it. I've also set breakpoints and NSLog() statements in the custom migration policy, and none of it runs, with or without NSInferMappingModelAutomaticallyOption Any hints as to why it seems unable to find the mapping model ?

    Read the article

  • DDD and Entity Base, Model using multiple identity types

    - by Thomas
    I have a model that looks like this: public interface IEntity { int Id { get; set; } } Then the idea is to have my entities inherit from this interface: public class User : IEntity { public int Id { get; set; } } However, one of my entities actually has a Guid as an identifier. public class UserSession { public Guid Id { get; set; } } I really would like all my entities inheriting from the same interface but that would force me to add an integer based identity column to the UserSession which is unnecessary since Guid is the identity, but it would keep the domain model nice since all entities would inherit from the same base. What options do I have in this scenario? Can I have two base interfaces, one for int and one for Guid? Should I add an identity column into the UserSession entity although it is unnecessary? I need the Guid so I can't just get rid of it and replace it with and integer. Any thoughts on best practices?

    Read the article

  • Entity Sql Group By problem, please help

    - by Zviadi
    Hello, help me please with this simple E-sql query: var qStr = "SELECT SqlServer.Month(o.DatePaid) as month, SqlServer.Sum(o.PaidMoney) as PaidMoney FROM XACCModel.OrdersIncomes as o group by SqlServer.Month(o.DatePaid)"; heres what I have. I have simple Entity called OrdersIncomes with ID,PaidMoney,DatePaid,Order_ID properties I want to select Month and Summed PaidMoney like this: month Paidmoney 1 500 2 700 3 1200 T-SQL looks like this and works fine: select MONTH(o.DatePaid), SUM(o.PaidMoney) from OrdersIncomes as o group by MONTH(o.DatePaid) results: 3 31.0000 4 127.0000 5 20.0000 (3 row(s) affected) but E-SQL doesnot work and I dont know what to do. here my E-SQL which needs refactoring: var qStr = "SELECT SqlServer.Month(o.DatePaid) as month, SqlServer.Sum(o.PaidMoney) as PaidMoney FROM XACCModel.OrdersIncomes as o group by SqlServer.Month(o.DatePaid)"; theres exception: ErrorDescription = "The identifier 'o' is not valid because it is not contained either in an aggregate function or in the GROUP BY clause." if I include o in group by clause, like: FROM XACCModel.OrdersIncomes as o group by o then I dont get summed and agregated results. is this some bug? or what Im doing wrong. heres Linq to Entities query and it works too: var incomeResult = from ic in _context.OrdersIncomes group ic by ic.DatePaid.Month into gr select new { Month = gr.Key, PaidMoney = gr.Sum(i = i.PaidMoney) };

    Read the article

  • Treating differential operator as algebraic entity

    - by chappar
    I know that this question is offtopic and don't belong here. But i didn't know somewhere else to ask. So here is the question. I was reading e:the story of a number by Eli Maor, where he treats differential operator as just like any algebraic entity. For example if we have a differential equation like y’’ + 5y’ - 6y = 0. This can be treaed as (D^2 + 5D – 6)y = 0. So, either y = 0 (trivial solution) or (D^2 + 5D – 6) = 0. Factoring out above equation we get (D-1)(D+6)= 0 with solutions as D = 1 and D = -6. Since D does not have any meaning on its own, multiplying by y on both the sides we get Dy = y and Dy = -6y for which the solutions are Ae^x and Be^-6x. Combining these 2 solutions we get Ae^x + Be^-6x. Now my doubt is this approach break when we have an equation like D^2y = 0. Which means y = 0 (again trivial) or D^2 = 0 which means D = 0. Now Dy = y*0 = 0. That means y = C ( a constant). The actual answer should be Cx. I know that it is stupidity to treat D^2 = 0 as D = 0, it led me to doubt the entire process of treating differential equation as algebraic equation. Can someone throw light on this? Or any other site where i might get answer?

    Read the article

  • Cannot add an entity that already exists.

    - by mazhar
    Code: public ActionResult Create(Group group) { if (ModelState.IsValid) { group.int_CreatedBy = 1; group.dtm_CreatedDate = DateTime.Now; var Groups = Request["Groups"]; int GroupId = 0; GroupFeature GroupFeature=new GroupFeature(); foreach (var GroupIdd in Groups) { // GroupId = int.Parse(GroupIdd.ToString()); } var Features = Request["Features"]; int FeatureId = 0; int t = 0; int ids=0; string[] Feature = Features.Split(',').ToArray(); //foreach (var FeatureIdd in Features) for(int i=0; i<Feature.Length; i++) { if (int.TryParse(Feature[i].ToString(), out ids)) { GroupFeature.int_GroupId = 35; GroupFeature.int_FeaturesId = ids; if (ids != 0) { GroupFeatureRepository.Add(GroupFeature); GroupFeatureRepository.Save(); } } } return RedirectToAction("Details", new { id = group.int_GroupId }); } return View(); } I am getting an error here Cannot add an entity that already exists. at this line GroupFeatureRepository.Add(GroupFeature); GroupFeatureRepository.Save();

    Read the article

  • Protecting sensitive entity data

    - by Andreas
    Hi, I'm looking for some advice on architecture for a client/server solution with some peculiarities. The client is a fairly thick one, leaving the server mostly to peristence, concurrency and infrastructure concerns. The server contains a number of entities which contain both sensitive and public information. Think for example that the entities are persons, assume that social security number and name are sensitive and age is publicly viewable. When starting the client, the user is presented with a number of entities, not disclosing any sensitive information. At any time the user can choose to log in and authenticate against the server, given the authentication is successful the user is granted access to the sensitive information. The client is hosting a domain model and I was thinking of implementing this as some kind of "lazy loading", making the first request instantiating the entities and later refreshing them with sensitive data. The entity getters would throw exceptions on sensitive information when they've not been disclosed, f.e.: class PersonImpl : PersonEntity { private bool undisclosed; public override string SocialSecurityNumber { get { if (undisclosed) throw new UndisclosedDataException(); return base.SocialSecurityNumber; } } } Another more friendly approach could be to have a value object indicating that the value is undisclosed. get { if (undisclosed) return undisclosedValue; return base.SocialSecurityNumber; } Some concerns: What if the user logs in and then out, the sensitive data has been loaded but must be disclosed once again. One could argue that this type of functionality belongs within the domain and not some infrastructural implementation(i.e. repository implementations). As always when dealing with a larger number of properties there's a risk that this type of functionality clutters the code Any insights or discussion is appreciated!

    Read the article

  • user interface pattern for associating single or many objects to an entity

    - by Samuel
    Need suggestions on implementing associating single or many objects to an entity. All soccer team players are registered individually (e.g. they are part of 'players' table) A soccer team has many players. The click sequence is like this:- a] Soccer team owner provides a name and brief description of the soccer team. b] Now it wants to add players to this team. c] You have the following button 'Add players to team' which lets you navigate to the 'View Players' page and lets you multi select users from there. Assuming this is a paginated list of players, how do you handle the following:- Do you provide a check box against each player and let the manager do a multi selection. If you need to add more players, it doesn't make sense to show the players who have been already added to the team. Do you mark those entries as not selectable or you would adding showing these entries. If you need to filter, do you provide search filters at the top of this page. Am looking for ideas on how to implement this or sites which have already done something similar.

    Read the article

  • how to query an embedded entity by using a query builder

    - by user577719
    I've searched quite a time for an answer to this question. Following Codesmell: @Entity public class Person { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) protected Integer id; @Column(nullable = true, length = 50) @Size(max = 50) private String name; @Embedded @Valid protected Adress adress; public void setId(Integer id) { this.id = id; } public Integer getId() { return this.id; } public void setName(String name) { this.name = name; } public void getName() { return this.name; } public void setAdress(Adress adress) { this.adress = adress; } public void getAdress() { return this.adress; } } @Embeddable public class Adress { @Column(nullable = false, length = 50) @Size(max = 50) @NotNull private String place; public void setPlace(String place) { this.place = place; } public void getPlace() { return this.place; } } public class PersonDaoJpa { public List<Ort> findByPerson(final Person person) { CriteriaBuilder builder = this.entityManager.getCriteriaBuilder(); CriteriaQuery<Person> query = builder.createQuery(Person.class); Root<Person> rootPerson = query.from(Person.class); List<Predicate> wherePredicates = new ArrayList<Predicate>(); if (person.getName() != null) { wherePredicates.add( builder.like(builder.lower(rootPerson.<String>get("name")), ort.getName().toLowerCase()) ); } Adresse adresse = ort.getAdresse(); if (adresse != null) { if(adresse.getPlace() != null) { // this won't work wherePredicates.add( builder.like(builder.lower(rootPerson.<String>get("person.adress.place")), adresse.getPlace().toLowerCase()) ); } } Predicate whereClause = builder.and(wherePredicates.toArray(new Predicate[0])); query.where(whereClause); return this.entityManager.createQuery(query).getResultList(); } } How can I access the Adress.place through rootPerson? rootPerson.get("place"), or rootPerson.get("adress.place") won't work...

    Read the article

  • Entity and N-Tier architecture in C#

    - by acadia
    Hello, I have three tables as shown below Emp ---- empID int empName deptID empDetails ----------- empDetailsID int empID int empDocuments -------------- docID empID docName docType I am creating a entity class so that I can use n-tier architecture to do database transactions etc in C#. I started creating class for the same as shown below using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace employee { class emp { private int empID; private string empName; private int deptID; public int EmpID { get; set; } public string EmpName { get; set; } public int deptID { get; set; } } } My question is as empDetails and empDocuments are related to emp by empID. How do I have those in my emp class. I would appreciate if you can direct me to an example. Thanks

    Read the article

  • How to know about results of work with COM component?

    - by chester89
    I suppose this question is more general than working with COM components. I have a .NET client written in C# and COM component written in pure Win32 API. Client side uses this component to perform some actions. How to know on the client that component did its job? I think it may be socket/pipe, with component writing to it about results, and client reading from it displaying progress to the user. What is the best way to do this?

    Read the article

  • With respect to gnome-session, what is a "component"?

    - by Alistair Buxton
    Under /usr/share/gnome-session/sessions are files which describe the different types of sessions available from gnome-session. In these files is a list of required components, eg for shell: RequiredComponents=gnome-shell;gnome-settings-daemon; or for fallback: RequiredComponents=gnome-panel;gnome-settings-daemon; This appears to be a list of executables, but it is not. If I change gnome-panel to some other type of panel, the session does not start, and I see the following errors in ~/.xsession-errors: gnome-session[2003]: WARNING: Unable to find required component 'xfce4-panel' So my question: What is a component, how are they defined, and where does gnome-session look for them?

    Read the article

  • Do I need the 'w' component in my Vector class?

    - by bobobobo
    Assume you're writing matrix code that handles rotation, translation etc for 3d space. Now the transformation matrices have to be 4x4 to fit the translation component in. However, you don't actually need to store a w component in the vector do you? Even in perspective division, you can simply compute and store w outside of the vector, and perspective divide before returning from the method. For example: // post multiply vec2=matrix*vector Vector operator*( const Matrix & a, const Vector& v ) { Vector r ; // do matrix mult r.x = a._11*v.x + a._12*v.y ... real w = a._41*v.x + a._42*v.y ... // perspective divide r /= w ; return r ; } Is there a point in storing w in the Vector class?

    Read the article

  • Making Separate Assemblies For Different Types Of Tests For The Same Component?

    - by sooprise
    I was told by a few members here that splitting up my unit tests into different assemblies for different components is the best way to structure unit tests. Now, I have a few questions about that idea. What are the advantages of this? Organization, and isolation of errors? Let's say I have a component named "calculator", and I create an assembly for the unit tests on "calculator". Would I create a separate assembly for the integration tests I want to run on "calculator"? Or is the definition of an integration test a test across multiple components, like "calculator" and whatever else, which would require a separate assembly to test both of them together? In that case, would I have one assembly to do all of the integration testing for every component combination?

    Read the article

  • Should the networking of my game be a component or a service?

    - by aalcutt
    I am working on a windows game and I am trying to understand the XNA GameComponents and GameServices classes and use. From what I understand about a component is that it has an Update method that gets call in every frame, and a service can be referenced from other components if needed. So the way I think a network component would work is that in its Update method it would receive and send data. It probably makes sense to receive the network data once per frame, but it doesn't for sending it. Shouldn't the game send its own updates to others the moment it has it to cut down on lag?

    Read the article

  • Mapping and metadata information could not be found for EntityType Exception

    - by dcompiled
    I am trying out ASP.NET MVC Framework 2 with the Microsoft Entity Framework and when I try and save new records I get this error: Mapping and metadata information could not be found for EntityType 'WebUI.Controllers.PersonViewModel' My Entity Framework container stores records of type Person and my view is strongly typed with class PersonViewModel which derives from Person. Records would save properly until I tried to use the derived view model class. Can anyone explain why the metadata class doesnt work when I derive my view model? I want to be able to use a strongly typed model and also use data annotations (metadata) without resorting to mixing my storage logic (EF classes) and presentation logic (views). // Rest of the Person class is autogenerated by the EF [MetadataType(typeof(Person.Metadata))] public partial class Person { public sealed class Metadata { [DisplayName("First Name")] [Required(ErrorMessage = "Field [First Name] is required")] public object FirstName { get; set; } [DisplayName("Middle Name")] public object MiddleName { get; set; } [DisplayName("Last Name")] [Required(ErrorMessage = "Field [Last Name] is required")] public object LastName { get; set; } } } // From the View (PersonCreate.aspx) <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<WebUI.Controllers.PersonViewModel>" %> // From PersonController.cs public class PersonViewModel : Person { public List<SelectListItem> TitleList { get; set; } } // end class PersonViewModel

    Read the article

< Previous Page | 80 81 82 83 84 85 86 87 88 89 90 91  | Next Page >