Search Results

Search found 675 results on 27 pages for 'pk'.

Page 4/27 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Sync LINQ-to-SQL DBML schema with SQL Server database

    - by Maxim Z.
    After creating a SQL Server 2008 database, I made a Linq-to-SQL schema in Visual Studio. Next, in the .dbml visual editor (in Visual Studio), I added PK-to-FK and PK-to-PK associations to the schema. How do I copy those associations that I created in Visual Studio over to the database? In other words, how do I sync with the DB?

    Read the article

  • Jackson object mapping - map incoming JSON field to protected property in base class

    - by Pete
    We use Jersey/Jackson for our REST application. Incoming JSON strings get mapped to the @Entity objects in the backend by Jackson to be persisted. The problem arises from the base class that we use for all entities. It has a protected id property, which we want to exchange via REST as well so that when we send an object that has dependencies, hibernate will automatically fetch these dependencies by their ids. Howevery, Jackson does not access the setter, even if we override it in the subclass to be public. We also tried using @JsonSetter but to no avail. Probably Jackson just looks at the base class and sees ID is not accessible so it skips setting it... @MappedSuperclass public abstract class AbstractPersistable<PK extends Serializable> implements Persistable<PK> { @Id @GeneratedValue(strategy = GenerationType.AUTO) private PK id; public PK getId() { return id; } protected void setId(final PK id) { this.id = id; } Subclasses: public class A extends AbstractPersistable<Long> { private String name; } public class B extends AbstractPersistable<Long> { private A a; private int value; // getter, setter // make base class setter accessible @Override @JsonSetter("id") public void setId(Long id) { super.setId(id); } } Now if there are some As in our database and we want to create a new B via the REST resource: @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Transactional public Response create(B b) { if (b.getA().getId() == null) cry(); } with a JSON String like this {"a":{"id":"1","name":"foo"},"value":"123"}. The incoming B will have the A reference but without an ID. Is there any way to tell Jackson to either ignore the base class setter or tell it to use the subclass setter instead? I've just found out about @JsonTypeInfo but I'm not sure this is what I need or how to use it. Thanks for any help!

    Read the article

  • Django comparing model instances for equality

    - by orokusaki
    I understand that, with a singleton situation, you can perform such an operation as: spam == eggs and if spam and eggs are instances of the same class with all the same attribute values, it will return True. In a Django model, this is natural because two separate instances of a model won't ever be the same unless they have the same .pk value. The problem with this is that if a reference to an instance has attributes that have been updated by middleware somewhere along the way and it hasn't been saved, and you're trying to it to another variable holding a reference to an instance of the same model, it will return False of course because they have different values for some of the attributes. Obviously I don't need something like a singleton , but I'm wondering if there some official Djangonic (ha, a new word) method for checking this, or if I should simply check that the .pk value is the same with: spam.pk == eggs.pk I'm sorry if this was a huge waste of time, but it just seems like there might be a method for doing this, and something I'm missing that I'll regret down the road if I don't find it.

    Read the article

  • Database table copying

    - by vbNewbie
    I am trying to rectify a previous database creation with tables that contains data that needs to be saved. Instead of recreating a completely new database since some of the tables are still reusable, I need to split a table that exists into 2 new tables which I have done. Now I am trying to insert the data into the 2 new tables and because of duplicate data in the old table I am having a hard time doing this. Old table structure: ClientProjects clientId PK clientName clientProj hashkey MD5 (clientname and clientProj) new table structures: client clientId PK clientName projects queryId PK clientId PK projectName I hope this makes sense. The problem is that in the old table for example you have clients with multiple clientIds.

    Read the article

  • Updating multiple tables with LinqToSql in one unit of work

    - by zsharp
    Table 1: int ID-a(pk) Table 2: int ID-a(pk), int ID-b(pk) Table 3: int ID-b(pk), string C I have the data to insert into Table 1. But I do not have the ID-a, which is autogenerated. I have many string C to insert in Table 3. I am trying to insert row into Table 1, get the ID-a to insert in Table 2 along with the ID-b that is auto-Generated in Table 3 when I submit each string C, all in one submission to db. Right now I am calling dc.SubmitChanges twice in same call. Is it efficient to have to submit changes twice on same DataContext or can this be combined further?

    Read the article

  • database setup for web application

    - by vbNewbie
    I have an application that requires a database and I have already setup tables but not sure if they match the requirements of the app. The app is a crawler which fetches web urls, crawls and stores appropriate urls and posts and all this is based on client requests which are stored as projects. So for each url stored there is one post and for client there are many projects and for each project there are many types of requests. So we get a client with a request and assign them a project name and then use the request to search for content and store the url and post. A request could already exist and should not be duplicated but should be associated with the right client and project and post etc. Here is my schema now: url table: urlId PK queryId FK url post table: postId PK urlId FK post date request table: queryId PK request client table: clientId PK client Name projectId FK project table: projectID PK queryID FK project Does this look right? or does anyone have suggestions. Of course my stored procedures and insert statements will have to be in depth.

    Read the article

  • Fluent NHibernate: Entity from one table, but reference will map to another tables?

    - by Andy
    Given the following tables: Product ----------- ProductId : int (PK) ProductVersion : int ProductHistory ----------- ProductId : int (PK) ProductVersion : int (PK) Item ----------- ItemId : int (PK) ProductId : int (FK) -- ProductId + ProductVersion relates to ProductHistory ProductVersion : int (FK) And the following classes: public class Product { } public class Item { public Product Product { get; set; } } What I want to happen is this; we get a Product from the Product table, assign it to Item.Product property. But that Item.Product property should map to ProductHistory. The idea is that only the latest version of a product is in the main Product table, so we allow customers to search against that table (so that if each product has 4 versions and there are 1000 products, we only need to query though 1000 products, not 1000 products * 4 versions of each). Any idea how to acomplish this? Thanks Andy

    Read the article

  • MySQL - query to return CSV in a field?

    - by StackOverflowNewbie
    Assume I have the following tables: TABLE: foo - foo_id (PK) TABLE: tag - tag_id (PK) - name TABLE: foo_tag - foo_tag_id (PK) - foo_id (FK) - tag_id (FK) How do I query this so that I get a result like this: ========================== | foo_id | tags | ========================== | 1 | foo, bar | | 2 | foo | | 3 | bar | -------------------------- Basically, I need all of foo's tags in one column, comma separated. Possible in MySQL?

    Read the article

  • ASP.net application advice needed

    - by c11ada
    hey all, im biulding a ASP.net application, which is connected to a database. the database design is as follows **Users Table** UserID `(PK) autonumber` Username **Question Table** QuestionID `(PK) autonumber` QuestionNumber QuestionText **Questionnaire Table** QuestionnaireID `(PK) autonumber` UserID `(FK) User Table` Date **Feedback Table** FeedbackID `(PK) autonumber` QuestionnaireID `(FK) Questionnaire Table` QuestionID `(FK) Questions Table` Answer Comment please can some one advise me on how I should go about inserting data into the questionnaire table and the feedback table. I know that the questionnaire table needs to be updated first. but the Questionnaire ID is linked to the feedback table, so how do I go about updating both tables ?

    Read the article

  • Foreign key refering to primary keys across multiple tables?

    - by sanjay bharkatiya
    hi , i have three tables say city,state and road 1) city - city_id(PK),name 2) state- Stt_id(PK),name 3) Road- Edge_id(PK), Admin_id(FK) where Admin_id refers to city_id and Stt_id both. This is done because the tables are too huge. say city_id contains 1,2,3 and Stt_id contains 4,5,6 now if i am inserting 1,2,3,4,5,6 in admin_id it is throuing an error .. what is the solution of my problem, regards sanjay

    Read the article

  • LinqToSQL: Not possible to update PrimaryKey?

    - by Zuhaib
    I have a simple table (lets call it Table1) that has a NVARCHAR field as the PK. Table1 has no association with any other tables. When I update Table1's PK column using LinqToSQL it fails. If I update other column it succeeds. I could delete this row and insert new one in Table1, but I don't want to. There is a transaction table which has Table1's PK column as a column. When the PK of Table1 is changed I want no effect in the transaction table. But when the row from Table1 is deleted, I want the transaction rows to be deleted. The cascading is done via Trigger. As there is not association between these two tables, if I update the PK column of Table1 using normal SQL, it works and there is no effect on the transaction table as expected. When I delete the row the trigger deletes the rows from transaction table. For this reason I can't delete and then add new row in Table1. So what can be done to successfully update the PrimaryKey of the Table1?

    Read the article

  • DuplicateKeyException in LINQ, but I've set auto increment and auto sync

    - by Fritos
    I'm getting a DuplicateKeyException error in my C# code. I've set Auto Generated = true, and Auto-Sync = OnInsert in my dbml. I'm not even touching the PK field in any manually written code (as seen below [My primary key field is actually called PK]). using (DeviceExerciseDataDataContext context = new DeviceExerciseDataDataContext()) { foreach(Data tgudData in data.Data) { tgd = new tableData(); tgd.FK = key; tgd.Time = tgudData.TimeStamp; tgd.Calories = Convert.ToInt32(tgudData.Calories); tgd.HeartRate = tgudData.AvgHr; tgd.BenchAngle = tgudData.Angle; tgd.WorkoutTarget = 0; tgd.Reps = tgudData.Reps; context.tableDatas.InsertOnSubmit(tgd); } context.SubmitChanges(); } This is the code for the column in the designer (columns are named PK and FK) [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PK", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL", IsPrimaryKey=true, IsDbGenerated=true)] public int PK { get { return this._PK; } set { if ((this._PK != value)) { this.OnPKChanging(value); this.SendPropertyChanging(); this._PK = value; this.SendPropertyChanged("PK"); this.OnPKChanged(); } } } [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FK", DbType="Int")] public System.Nullable<int> FK { get { return this._FK; } set { if ((this._FK != value)) { this.OnFKChanging(value); this.SendPropertyChanging(); this._FK = value; this.SendPropertyChanged("FK"); this.OnFKChanged(); } } }

    Read the article

  • Inheritance in tables - structure problem

    - by Naor
    I have 3 types of users in my system. each type has different information I created the following tables: BaseUser(base_user_id, username, password, additional common data) base_user_id is PK and Identity UserType1(user_id, data related to type1 only) user_id is PK and FK to base_user_id UserType2(user_id, data related to type2 only) user_id is PK and FK to base_user_id UserType3(user_id, data related to type3 only) user_id is PK and FK to base_user_id Now I have relation from each type of user to warehouses table. Users from type1 and type2 should have only warehouse_id and users from type3 should have warehouse_id and customer_id. I thought about this structure: WarehouseOfUser(base_user_id,warehouse_id) base_user_id is FK to base_user_id in BaseUser WarehouseOfTyp3User(base_user_id,warehouse_id, customer_id) base_user_id is FK to base_user_id in BaseUser The problem is that such structure allows 2 things I want to prevent: 1. add to WarehouseOfTyp3User data of user from type2 or type1. 2. add to WarehouseOfUser data of user from type3. what is the best structure for such case?

    Read the article

  • Hibernate one to one with multiple columns

    - by Erdem Emekligil
    How can i bind two columns, using @OneToOne annotation? Lets say I've 2 tables A and B. Table A: id1 (primary key) id2 (pk) other columns Table B: id1 (pk) id2 (pk) other columns In class A i want to write something like this: @OneToOne(fetch = FetchType.EAGER, targetEntity = B.class) @JoinColumn(name = "id1 and id2", referencedColumnName = "id1 and id2") private B b; Is it possible to do this using annotations? Thanks.

    Read the article

  • Help needed to construct a SQL query

    - by song202y
    Need your help to get the list of suggested friends (who aren't friends of the current user but are friends of 2 or more of the current user's friends). The primary ordering should put people at the same school at the top, and the secondary ordering should put people with more common friends (that is, the number of people who are friends of that person and the current user) near the top. Users: user_id PK, user_name Profiles: user_id PK, school_name, ... Friendships: id PK, user_id FK, friend_id FK Thank you in advance. Joe

    Read the article

  • Wrong SQLServer syntax: need help!

    - by user512602
    Hi, this is what I want to achieve: 4 tables are involved: Players with PlayerID as PK, Competitions with CompetID as PK Results with ResultID as PK and CompetID as FK And the 4th table: PlayerResultts with ResultID + PlayerID as PK and CompetID as new column I created. Competitions, results and PlayerResults are already populated and quite large (300000 PlayerResults so far). In order to populate the PlayerResults.CompetID column, I try a Update ... (Select....) request but I'm not aware of the right syntax and it fails. Here is my feeble attempt: update PlayerResults set competid = (select distinct(r.competid) from results r, playerresults p where r.resultID = p.resultid) Error is (of course): "Msg 512, Level 16, State 1, Line 1 Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , , = or when the subquery is used as an expression." Can someone put me in the right direction? TIA

    Read the article

  • solution for updating table based on data from another table

    - by I__
    i have 2 tables in access this is what i need: 1. if the PK from table1 exists in table2, then delete the entire record with that PK from table2 and add the entire record from table1 into table2 2. if the PK does not exist then add the record i need help with both the sql statement and the VBA i guess the VBA should be a loop, going through every record in table1. inside the loop i should have the select statement

    Read the article

  • if exists, update, else insert new record

    - by I__
    i am inserting values into a table if the record exists already replace it, and if it does not exist then add a new one. so far i have this code: INSERT INTO table_name VALUES (value1, value2, value3,...) where pk="some_id"; but i need something like this if not pk="some_id" exists then INSERT INTO table_name VALUES (value1, value2, value3,...) where pk="some_id"; else update table_name where pk="some_id" what would be the correct SQL syntax for this? please note that i am using sql access and that i guess it can be a combination of vba and sql

    Read the article

  • GridView edit problem If primary key is editable (design problem)

    - by Nassign
    I would like to ask about the design of table based on it's editability in a Grid View. Let me explain. For example, I have a table named ProductCustomerRel. Method 1 CustomerCode varchar PK ProductCode varchar PK StoreCode varchar PK Quantity int Note text So the combination of the CustomerCode, StoreCode and ProductCode must be unique. The record is displayed on a gridview. The requirement is that you can edit the customer, product and storecode but when the data is saved, the PK constraint must still persist. The problem here is it would be natural for a grid to be able to edit the 3 primary key, you can only achieve the update operation of the grid view by first deleting the row and then inserting the row with the updated data. An alternative to this is to just update the table and add a SeqNo, and just enforce the unique constraint of the 3 columns when inserting and updating in the grid view. Method 2 SeqNo int PK CustomerCode varchar ProductCode varchar StoreCode varchar Quantity int Note text My question is which of the two method is better? or is there another way to do this?

    Read the article

  • There is a system alert of (13, 'Permission denied'), how to solve that?

    - by Semanty
    def upload_file(request, step_id): def handle_uploaded_file (file): current_step = Step.objects.get(pk=step_id) current_project = Project.objects.get(pk=current_step.project.pk) path = "%s/upload/file/%s/%s" % (settings.MEDIA_ROOT, current_project.project_no, current_step.name) if not os.path.exists (path): os.makedirs(path) fd = open(path) for chunk in file.chunks(): fd.write(chunk) fd.close() if request.method == 'POST': form = UploadFileForm(request.POST, request.FILES) if form.is_valid(): handle_uploaded_file(request.FILES['file']) return HttpResponseRedirect('/success/url/') else: form = UploadFileForm() return render_to_response('projects/upload_file.html', { 'step_id': step_id, 'form': form, })

    Read the article

  • Question on different ways to link tables

    - by dotnetdev
    What is the difference between linking two tables and then the PK is an FK in the other table, but the FK has not got the primary key option (so it does not have the gold key), and having the PK in one table as a PK in another table? Am I right to think that the second option is for a many-to-many relationship? Thanks

    Read the article

  • Android FTP seek Bar issue

    - by Androi Developer
    I am trying to Upload & Download file to server using FTP and Download File using HTTP i am able to do this, my problem is when i am trying to show seek bar with Upload status of file using ftp then it's not showing. In this attached image Using HTTP it's showing seekbar with Network spped like this i need to display seek bar & Network sppeed in FTP. Below code i wrote for FTP to upload file into server. Code:-- // Upload System.out.println("upload test is called"); //Toast.makeText(con, "upload FTP test is called", Toast.LENGTH_SHORT).show(); //ContextWrapper context = null; //assetManager= context.getAssets(); assetManager = getResources().getAssets(); input1 = assetManager.open("hello.txt"); final long started = System.currentTimeMillis(); int size = input1.available(); //byte[] buffer = new byte[size]; byte dataByte[] = new byte[1024]; //input1.read(buffer); //String data = "ZK DATA TESTER TEST DATA1sdfsdf"; String data = input1.toString(); System.out.println("dat value is........"+data); final int lenghtOfFile = data.getBytes().length; //final int lenghtOfFile = input1.getBytes().length; System.out.println("length of file....."+lenghtOfFile); ByteArrayInputStream in = new ByteArrayInputStream( data.getBytes()); //toast("Uploading /test.txt"); //Toast.makeText(con,"File Size : " +data.getBytes().length + " bytes",Toast.LENGTH_SHORT).show(); //byte b[] = new byte[1024]; long total = 0; long sleepingTime= 0; System.out.println("started time --"+started); updateUI(status, "Uploading"); while ((count = in.read(dataByte)) != -1) { System.out.println("read value is...."+in.read(dataByte)); while (sleep1) { Thread.sleep(1000); System.out.println("ftp upload is in sleeping mode"); sleepingTime +=1000; } System.out.println("Total count --"+count); total += count; System.out.println("Only Total --"+total); final int progress = (int) ((total * 100) / lenghtOfFile); final long speed = total; //duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; boolean result = ObjFtpCon.storeFile("/test.txt", input1); //boolean result = ObjFtpCon.storeFile(map.get("file_address").toString()+"/test.txt", input1); duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; /* runOnUiThread(new Runnable() { public void run() { bar.setProgress(progress); // trans.setText("" + progress); //duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; //duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; //real_time.setText(duration + " secs"); if (duration != 0) { test_avg.setText((((speed / duration)*1000)*0.0078125) + " kbps"); if (pk <= (speed / duration) / 1024) { pk = (speed / duration) / 1024; } if (pk <= ((speed / duration)*1000)*0.0078125) { pk = (long)(((speed / duration)*1000)*0.0078125); } //peak.setText(pk + " kbps"); } } });*/ //in.close(); if (result) { updateUI(status, "Uploaded"); // toast("Uploading succeeded"); // toast("Uploaded at /test.txt"); //duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; System.out.println("curreent time..... "+System.currentTimeMillis()); System.out.println("started time --"+started); System.out.println("sleep tome...."+sleepingTime); System.out.println("duration is....."+duration); runOnUiThread(new Runnable() { public void run() { bar.setProgress(progress); // trans.setText("" + progress); //duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; real_time.setText(duration + " secs"); if (duration != 0) { test_avg.setText((speed / duration) / 1024 + " kbps"); if (pk <= (speed / duration) / 1024) { pk = (speed / duration) / 1024; } peak.setText(pk + " kbps"); } } }); } /*while(!result){Thread.sleep(1000);}*/ } in.close();

    Read the article

  • How to make Connect Communications VPN connection in 10.10?

    - by Bilal Mohammad Qazi
    these steps were send by my iSP admin for ver10.10 and i'm using 11.10... step 1 sucessfully implemented till point 7 after that the problems are marked after '//' Step 2 i cannot completely do the step 2 How to make Connect Communications VPN connection in Ubuntu 10.10. 1st Step:- 1- Go to System > Administration > Synaptic Package Manage 2- Search for “PPTP”, check “network-manager-PPTP” and click “Apply” 3- Click on the Network Manager tray icon with your right mouse button and choose “Edit Connections…”. 4- Go to the “VPN” tab and click “Add”. 5- Choose “Point-to-Point Tunneling Protocol (PPTP)” as the VPN Connection Type 6- Check the VPN Connection Type and click “Create”. 7- Give your VPN connection a name and assign all the necessary information • Gateway = blue.connect.net.pk if you got Blue Package or • Gateway = green.connect.net.pk if you got Green Package or • Gateway = blueplus.connect.net.pk if you got BluePlus Package or • Gateway = red.connect.net.pk if you got Red Package • User name = Connect Communications Userid • Password = Connect Communications Password 8- Now Click on “Advanced” Authentication • Unchecked “PAP" // cannot uncheck • Unchecked “MSCHAP" // cannot uncheck • Unchecked “CHAP" • Checked only “MSCHAPv2" EAP shown in ver11.10 and cannot be unchecked Security And Compression. • Unchecked “Use Point-to-Point encryption (MPPE)”. • Unchecked “Allow statefull encryption”. • Unchecked “Allow BSD data Compression”. • Unchecked “Allow Deflate data Compression”. • Unchecked “Use TCP Header Compression”. • Unchecked “Send PPP echo Packets” Then Press “OK” then “Apply”. 9-Now you are able to connect to the specified VPN connection via the Networking Manager Then you can connect to VPN in the menu bar and your Internet icon will have a lock when the connection is successful. 2nd Step:- Open Terminal window. First, you open a terminal (Applications > Accessories > Terminal): Run command “sudo” Now gave root Password. Then run command “netstat -r -n” It will show some lines and for example from the last line pick the IP from 2nd column like 10.111.0.1 0.0.0.0 10.111.0.1 0.0.0.0 UG 0 0 0 eth0 Now run the fallowing command. echo “route add -net 10.101.8.0 netmask 255.255.252.0 gw 10.152.24.1” > /etc/rc.local note :- 10.111.0.1 is an example IP now run “ sh /etc/rc.local “

    Read the article

  • Analysing Indexes - count *

    - by GrumpyOldDBA
    In my presentations on indexing I have always said that you should explore the advantages of covering your clustered index with a secondary index. In circumstances where you might want to just return values form the PK ( assuming it's your clustered index ) a secondary index will be more efficient especially when the row size is wide. Any operation on a clustered index will always return the entire row, so select ID from dbo.mytable where ID is the clustered PK integer will return not just the...(read more)

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >